Issue #4483 has been updated by James Turnbull.

Status changed from Unreviewed to Accepted


----------------------------------------
Bug #4483: Already-loaded classes shadow autoloaded classes, violating 
namespace resolution order
http://projects.puppetlabs.com/issues/4483

Author: Paul Berry
Status: Accepted
Priority: Normal
Assigned to: Paul Berry
Category: 
Target version: 
Affected version: 2.6.1rc1
Keywords: 
Branch: 


I found this bug while investigating issue #4211.  The failure applies to 
0.25.5 as well as 2.6.1rc1.

If I run "puppet init.pp", supplying the following source files:

init.pp:
<pre>
class test::foo {
  include bar
}
include test::foo
</pre>

test/foo/bar.pp:
<pre>
class test::foo::bar {
  notify {"test::foo::bar": }
}
</pre>

I get this output:

<pre>
notice: test::foo::bar
notice: /Stage[main]/Test::Foo::Bar/Notify[test::foo::bar]/message: defined 
'message' as 'test::foo::bar'
</pre>

This is expected; the statement "include bar" is interpreted as referring to 
"test::foo::bar", so it causes "test/foo/bar.pp" to be autoloaded.

However, if I change init.pp to this:
<pre>
class test::bar {
  notify {"test::bar": }
}
class test::foo {
  include bar
}
include test::foo
</pre>

I now get this output:

<pre>
notice: test::bar
notice: /Stage[main]/Test::Bar/Notify[test::bar]/message: defined 'message' as 
'test::bar'
</pre>

This is unexpected.  The statement "include bar" should be resolved by looking 
first in test::foo, then in test, then at toplevel.  So it should still resolve 
to "test::foo::bar".

Further experimentation reveals that the shadowing effect only occurs because 
"test/foo/bar.pp" hasn't been loaded yet.  If you manually force that file to 
be loaded by changing init.pp to this:
<pre>
import "test/foo/bar.pp"
class test::bar {
  notify {"test::bar": }
}
class test::foo {
  include bar
}
include test::foo
</pre>

Then the expected behavior is restored.



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to