From 06b58b76f31d491371d0ab0c38cec33c1c7ba4ab Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 25 Jul 2012 22:07:12 -0700 Subject: =?UTF-8?q?Don=E2=80=99t=20let=20=3F:=20folding=20affect=20truncat?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit truncate(${\1} ? foo : bar, 0) and truncate(1 ? foo : bar, 0) should behave the same way, but were treated differently, due to the way ?: is folded in the latter case. Now that foldedness is recorded in the op tree (cc2ebcd7902), we can use the OPpCONST_FOLDED flag to distin- guish truncate(1 ? foo : bar, 0) from truncate(foo, 0). --- op.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'op.c') diff --git a/op.c b/op.c index 52e600ff8a..b4332271ef 100644 --- a/op.c +++ b/op.c @@ -10031,7 +10031,8 @@ Perl_ck_trunc(pTHX_ OP *o) if (kid->op_type == OP_NULL) kid = (SVOP*)kid->op_sibling; if (kid && kid->op_type == OP_CONST && - (kid->op_private & OPpCONST_BARE)) + (kid->op_private & (OPpCONST_BARE|OPpCONST_FOLDED)) + == OPpCONST_BARE) { o->op_flags |= OPf_SPECIAL; kid->op_private &= ~OPpCONST_STRICT; -- cgit v1.2.1