[Puppet - Bug #13323] Issues with variable scoping.
2012-04-01 01:11:12 GMT
I definitely understand the logic behind this. My issue is that the language doesn’t appear to consistently recognize $foo::bar and $::foo::bar as the same variable depending on the scope, which leads to very confusing code.
I personally believe that this should either be consistent across the board, or a parse error at some level so that you don’t have code that behaves in an unexpected manner.
Thanks for looking into this!
Bug #13323: Issues with variable scoping.
- Author: Trevor Vaughan
- Status: Needs Decision
- Priority: Normal
- Assignee: Pieter van de Bruggen
- Category: language
- Target version:
- Affected Puppet version: 2.7.12
- Keywords: ambiguity, variable, scope
- Branch:
According to http://docs.puppetlabs.com/guides/scope_and_puppet.html, we should be attempting to use fully qualified variable scoping across the board. However, I’ve run into a situation where there appear to be some serious issues.
Example:
class foo ($var1 = ‘something’) {}
class foo::baz { if $foo::var1 == ‘something’ { do something } }
class bar { $foo::var1 <– does not exist because it looks in bar::foo
class { ‘::foo’: var1 => ‘baz’ }
}
class bar::foo { stuff… }
The issue is that $::foo::var1 is NOT the same as $foo::var1 though both can be successfully declared anywhere across the manifest space. This causes very non-deterministic actions when using both variants though they should both really be the same thing.
So, what is correct? Should we always use $::variable::thing or is the code incorrect and they should both be valid at the top scope when there is no lower scope overriding that variable?
--You received this message because you are subscribed to the Google Groups "Puppet Bugs" group.
To post to this group, send email to puppet-bugs <at> googlegroups.com.
To unsubscribe from this group, send email to puppet-bugs+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
RSS Feed