[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: 'name conflict for module' with Compat-5.1
- From: "Jarno van Rooyen" <jarno.vanrooyen@...>
- Date: Fri, 27 May 2005 17:43:32 +0200
I'm not quite sure if I'm using the package feature wisely but this is what I
have. I'm trying to load a package structure that looks like this:
In the root folder I have a file called Tests.lua to load the components.
Note the module keyword at the top:
The Tests folder has a file called Component1.lua. It loads the features.
The Feature1.lua file is in Tests/Component1 and is a module of the
I create a global value called Component1 (it can be anything but a table)
e.g. Component1 = function() end
Then I try to require 'Tests'. I end up with
compat-5.1.lua:122: name conflict for module `Tests.Component1'
The error is triggered from in ./Tests/Component1/Feature1.lua:1 in the
implementation of 'module "Tests.Component1"'. By the time this line is
executed, the Tests namespace has been created. (That happens in ./Tests.lua)
However, at this time the Tests namespace does not contain the Component1
namespace. (The Tests table is empty except for the _NAME, _PACKAGE and _M).
The Component1 namespace and table only gets created in Feature1.lua.
However, the lookup of the name "Component1" in the Tests namespace produces
the global Component1 value. This causes the "name conflict".
This can be removed by changing 1 line in compat-5.1.lua. In the getfield
t = t[w]
t = rawget( t, w )
Now the lookup for 'Component1' on the Tests table fails because the global
namespace is not searched. The Component1 namespace is now also created
I have not tested this with work6. Is this the intended behaviour? This
that one can have a namespace A.B, but not have the B table an element of A.
B can be a "global".
Jarno van Rooyen