diff options
author | Father Chrysostomos <sprout@cpan.org> | 2014-08-25 14:54:30 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2014-08-25 22:17:02 -0700 |
commit | 8380b69016c69919ccf4d4694e396db6a7a91c91 (patch) | |
tree | be94449b6739f3d4dfbfb13481acb13b5fa4944d /t/base | |
parent | 7fa2fdc07ed9697d677cb165e07b12495e856d59 (diff) | |
download | perl-8380b69016c69919ccf4d4694e396db6a7a91c91.tar.gz |
Stop trying to disambiguate {} after $
$ ./perl -Ilib -e '${function_with_side_effects,42}'
$ ./perl -Ilib -e '${Function_with_side_effects,42}'
syntax error at -e line 1, near "${"
Execution of -e aborted due to compilation errors.
Why is the second one a syntax error?
Because the lexer is trying to disambiguate between a block and a hash
when it sees ‘{’ after ‘$’. But an anonymous hash constructor cannot
come after a funny character, so any time it chooses the hash inter-
pretation over the blocky one, a syntax error ensues.
Diffstat (limited to 't/base')
-rw-r--r-- | t/base/lex.t | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/t/base/lex.t b/t/base/lex.t index d75fa57b8f..7604ee1e7d 100644 --- a/t/base/lex.t +++ b/t/base/lex.t @@ -1,6 +1,6 @@ #!./perl -print "1..92\n"; +print "1..93\n"; $x = 'x'; @@ -438,3 +438,9 @@ print "ok $test - => quotes keywords across lines\n"; $test++; # [perl #80368] print "not " unless eval '"a\U="' eq "a="; print "ok $test - [perl #80368] qq <a\\U=>\n"; $test++; + +sub Function_with_side_effects { $_ = "sidekick function called" } +print "not " unless + (eval '${Function_with_side_effects,\$_}' || $@) + eq "sidekick function called"; +print "ok $test - \${...} where {...} looks like hash\n"; $test++; |