Issue #9518 has been updated by Daniel Pittman.
To add some more notes: I think that the behaviour is correct, but very confusing, in the current code. Specifically: `$var` only ever refers to the *top level* binding. There isn't actually a variable of that name in either enclosing scope. When you refer to `$var`, `$test1::var` and `$test2::var` in that, you are picking up that we (incorrectly) treat that as an alias for the global variable in that scope, *and* allow visibility of that outside the class itself. So, because they all refer to the same variable they *also* see the same dynamic binding for the value of the variable. Possible solutions: 1. Treat each as a genuine variable, with the "current content", in each scope. This allows looking through the dynamic binding history of the variable. 2. Treat each lookup other than at global scope as an error. (eg: $test2::var fails, $::var works) This fixes the inconsistency. 3. ...huge profit? I can't identify a third option, but suspect there might be some other way to view this. Suggestions welcome. :) ---------------------------------------- Bug #9518: Array scope different from string scope: https://projects.puppetlabs.com/issues/9518 Author: Zach Leslie Status: Accepted Priority: Normal Assignee: Category: Target version: Affected Puppet version: 2.7.1 Keywords: Branch: The following code: <pre> $var=["top"] class test1 { $var+=["test1"] } class test2 { $var+=["test2"] notice("Top: $::var Test1: ${test1::var} Test2: ${test2::var}") } class{ "test1": } class{ "test2": } </pre> produces: <pre> notice: Scope(Class[Test2]): Top: top Test1: toptest1 Test2: toptest2 </pre> If the array is changed to a string as such: <pre> $var="top" class test1 { $var+="test1" } class test2 { $var+="test2" notice("Top: $::var Test1: ${test1::var} Test2: ${test2::var}") } class{ "test1": } class{ "test2": } </pre> The behavior changes. <pre> notice: Scope(Class[Test2]): Top: toptest1test2 Test1: toptest1test2 Test2: toptest1test2 </pre> This appears to be inconsistent scoping and should be fixed. I've been informed that its been around for a long time. Tested on 2.7.1 and 2.7.4. -- 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.
