On Monday, December 15, 2014 11:07:45 AM UTC-6, John Sellens wrote:
>
> I couldn't find any reference to this different behaviour, so I'm 
> wondering if anyone knows if this is intentional. 
>
> I use a bunch of defined types, and with the future parser, when I refer 
> to a variable in a template, it seems that the default scope is not the 
> scope of the class. 
>
> e.g. in a template, <%= @a %> no longer refers to $a from the current 
> class. 
>
> This is different behaviour than with the current parser, and doesn't 
> seem to match the documentation I've found, or the behaviour with the 
> standard types. 
>
>

The behavior you describe under the future parser perfectly matches the scope 
documentation 
<https://docs.puppetlabs.com/puppet/latest/reference/lang_scope.html> and 
the templating documentation 
<https://docs.puppetlabs.com/guides/templating.html#referencing-variables>.  
The old behavior you describe is buggy, written up as PUP-1220 
<https://tickets.puppetlabs.com/browse/PUP-1220> (among others).  I don't 
quite see how it is comparable to anything done by a native type, whether 
provided with Puppet or not.

 

> Is it expected that a defined type evaluates templates in a 
> (seemingly) different scope? 
>
>

Yes, it is.  As documented in the scope specifications linked above, 
defined type bodies establish anonymous local scopes that are not related 
to the scope associated with the class that declares them.  That should 
apply to templates' view of variables exactly the same way it applies in 
the DSL, as the templating docs specifically limit the variables directly 
available within a template to those that are in (DSL) scope at the point 
where the template is evaluated.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/232338f5-3538-4f65-be56-9fe1168f06c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to