[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: 'name conflict for module' with Compat-5.1
- From: "Jarno van Rooyen" <jarno.vanrooyen@...>
- Date: Wed, 1 Jun 2005 09:58:48 +0200
> > I'll try to explain my setup:
> > I want tables (containing namespaces) as follows:
> > Tests
> > Tests.Component1 -- Contains all the tests for Component1
> May I suggest a different setup?
> What about
> and then use only
> require "Tests.Component1.Feature1"
> whenever you need to test feature1 from component1. The file could be only
> module "Tests.Component1"
> ... some more code to implement tests for feature 1.
> Notice that you can have more than one FeatureN file using the same module
> namespace (although local functions won't be visible among the different
This could work. How would I provide my users with the ability to load all
the tests for component1? How would they load the tests for all the
components? (BTW: I think there was a discussion on this somewhere else)
> > To summarise: It is possible to either prevent a library from loading or
> > loading it into unexpected tables by declaring global variables with
> > implementation of compat.
> I have to insist that apparently that is not the issue here, using the
> above namespace scheme should make things easier for you and your users,
I've managed to reduce all of this into 1 file that demonstrates the issue.
Put all of this into ./Tests.lua. One could also distribute it over the files
as indicated by the comments
-- In ./Tests/Component1.lua
-- In ./Tests/Component1/Feature1.lua
Start Lua and assign something to the global variable Component1. Now require
- Component1 = function() end
- require 'Tests'
The response I see is (Lua 5.0.2, compat-5.1r2):
compat-5.1.lua:122: name conflict for module `Tests.Component1'
[C]: in function `error'
compat-5.1.lua:122: in function `module'
Tests.lua:8: in function `f'
compat-5.1.lua:79: in function `require'
stdin:1: in main chunk
By making the change to getfield(), this will work.