This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Stop trying to disambiguate {} after $
authorFather Chrysostomos <sprout@cpan.org>
Mon, 25 Aug 2014 21:54:30 +0000 (14:54 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 26 Aug 2014 05:17:02 +0000 (22:17 -0700)
commit8380b69016c69919ccf4d4694e396db6a7a91c91
treebe94449b6739f3d4dfbfb13481acb13b5fa4944d
parent7fa2fdc07ed9697d677cb165e07b12495e856d59
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.
t/base/lex.t
toke.c