[perl #119055] Make qq with no vars read-only
authorFather Chrysostomos <sprout@cpan.org>
Sun, 28 Jul 2013 21:10:10 +0000 (14:10 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Jul 2013 21:10:10 +0000 (14:10 -0700)
commit07a05c08e908090dbce2612fa6da7496067a0d53
tree5c1283febe11a8e6e021c5aeb8543d82eb32c7ce
parent7a5b1e22b731c65eb2ce1c4fc188bab00ac4ae8d
[perl #119055] Make qq with no vars read-only

In commit 2484f8db I stopped constant folding from changing the read-
onliness of expressions like 1+2, which should return mutable values,
seeing that ${\1}+2 returns a mutable value.  (After all, constant
folding is supposed to be solely an optimisation, without changing
behaviour.)

This is accomplished by turning on the PADTMP flag, which tells opera-
tors like \ to copy the scalar.

I did not realise at the time that some qq strings like "hello\n" and
qq "foo" (but not just "foo") are implemented using constant folding.
The lexer outputs something like stringify("foo"), which is compiled
down to a stringify op with a constant ("foo") as its only child.

In this case we really do want qq"foo" to be treated as a single con-
stant.  That it is implemented using folding while "foo" is not is an
implementation detail we should hide.

So turn off the PADTMP flag when folding a stringify op.
op.c
t/comp/fold.t