The Puppet Labs Issue Tracker has Moved:

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using See the following page for information on filing tickets with JIRA:

Feature #5027

Issue warnings when using dynamic scope

Added by Paul Berry over 5 years ago. Updated almost 4 years ago.

Status:ClosedStart date:04/14/2011
Priority:HighDue date:
Assignee:-% Done:


Target version:2.7.0
Affected Puppet version: Branch:

We've Moved!

Ticket tracking is now hosted in JIRA:


This ticket captures a decision made on the developer mailing list on Oct 12 (see email thread “Questions about variable scope”).

In Puppet version 2.7, a deprecation warning should be issued whenever a variable reference takes place or a resource default is applied as a result of dynamic scoping.

Dynamic scoping means that variables and resource defaults defined in class A also take effect in classes that A includes. The warning should advise users that this feature will be removed in a future version of Puppet, so they should start using other puppet features (such as parameterized classes) to achieve the desired effect.


Bug #7111: Modify scoping warning/deprecation messageClosed

Bug #13312: Dynamic scoping deprecation warnings should be given at t...Closed

Related issues

Related to Puppet - Refactor #5063: Internal global variable lookups should not be scoped Closed 10/20/2010


#1 Updated by Paul Berry over 5 years ago

Here is an example of a .pp file that should produce the warning:

$foo = 'foo_value'

class a {
    $bar = 'bar_value'

    include b

class b inherits c {
    notify { $baz: } # should not generate a warning -- inherited from class c
    notify { $bar: } # should generate a warning -- uses dynamic scoping
    notify { $foo: } # should not generate a warning -- comes from top scope

class c {
    $baz = 'baz_value'

include a

This should produce three notify messages: “foo_value”, “bar_value”, and “baz_value”. Only the notify statement for $bar should produce a deprecation warning.

#2 Updated by Nick Lewis over 5 years ago

  • Status changed from Accepted to In Topic Branch Pending Review
  • Branch set to

Scopes now track how they acquired their parents (dynamic scope from being included vs. inheritance). This allows us to simulate static scope when looking up variables, compare it to the result of the dynamic lookup, and issue a warning if the results differ. Such a warning is only issued once per compile.

#3 Updated by Markus Roberts over 5 years ago

  • Assignee changed from Paul Berry to Markus Roberts

I’m working on an alternative implementation which I believe will be cleaner but may just serve to educate me.

#4 Updated by Markus Roberts about 5 years ago

  • Status changed from In Topic Branch Pending Review to Ready For Checkin
  • Branch changed from to

Paul’s eventual acquiescence to my version on puppet-dev didn’t make it to the ticket.

#5 Updated by Nigel Kersten almost 5 years ago

  • Status changed from Ready For Checkin to Needs More Information

Is it possible to get this rebased against the current master?

Will this solution also identify resource defaults ? (the example above doesn’t use them)

#6 Updated by Nigel Kersten almost 5 years ago

  • Status changed from Needs More Information to In Topic Branch Pending Review
  • Assignee deleted (Markus Roberts)

Rebased here:

#7 Updated by Nick Lewis almost 5 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release

The branch on the ticket has been merged, with fixups to the warnings, to next in commit:2dfa0afb57ec80f451a54ef96341d413819c14c7.

#8 Updated by Dominic Maraglia almost 5 years ago

  • Status changed from Merged - Pending Release to Closed

Fix verified in [[]]

Test checked to puppet-acceptance: 18a26d9..8e12139 master –> master

#9 Updated by James Turnbull over 4 years ago

  • Target version changed from 2.7.x to 2.7.0

Also available in: Atom PDF