summaryrefslogtreecommitdiffstats
path: root/examples/modules/sample-module/lib
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2010-02-08 20:17:38 +0100
committerJames Turnbull <james@lovedthanlost.net>2010-03-25 16:20:52 +1100
commit5d10f65745ce78e71e9a4cfce7f1f60c45db2501 (patch)
tree89b8723c1894ced7732cf298e797052e3021f8f1 /examples/modules/sample-module/lib
parentfbedb999e4f4cc8020bc6be4a1d8868368c3ed7f (diff)
downloadpuppet-5d10f65745ce78e71e9a4cfce7f1f60c45db2501.tar.gz
puppet-5d10f65745ce78e71e9a4cfce7f1f60c45db2501.tar.xz
puppet-5d10f65745ce78e71e9a4cfce7f1f60c45db2501.zip
Fix #3155 - prevent error when using two matching regex in cascade
The following manifest: case $var { /match/: { if $var =~ /matchagain/ { } } } is failing because the "=~" operators when matching sets an ephemeral variable in the scope. But the case regex also did it, and since they both belong to the same scope, and Puppet variables are immutables, the scope raises an error. This patch fixes this issue by adding to the current scope a stack of ephemeral symbol tables. Each new match operator or case/selector with regex adds a new scope. When we get out of the case/if/selector structure the scope is reset to the ephemeral level we were when entering it. This way the following manifest produces the correct output: case $var { /match(rematch)/: { notice("1. \$0 = $0, \$1 = $1") if $var =~ /matchagain/ { notice("2. \$0 = $0, \$1 = $1") } notice("3. \$0 = $0, \$1 = $1") } } notice("4. \$0 = $0") And the output is: 1. $0 = match, $1 = rematch 2. $0 = matchagain, $1 = rematch 3. $0 = match, $1 = rematch 4. $0 = Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'examples/modules/sample-module/lib')
0 files changed, 0 insertions, 0 deletions