This turns out to be a fascinating bug, not the usual "useless use of useless 
use".

We were cloning a closure twice because we were calling EXPR twice on the same 
expression, namely inside the 'for' rule that looks for a C-style for loop.  It 
was doing this inside a <?before> because it was just conjecturally seeing if 
it could parse 3 expressions separated by two semicolons.  In general, we 
should not have side effects when conjecturally parsing, but in this case EXPR 
could call down into the code that thunkifies statements and xx and such, and 
clone a copy of the thunk into the current lexical scope, which is stored in 
$*W rather than in the current parse tree.  So when the AST was thrown away, 
the extra code remained, and triggered the useless use warning, because it 
really was, in some sense.

The solution is to set $*SUPPOSING=1 inside <?before> and <?after>, and then 
prevent such spurious side effects when we're merely parsing conjecturally.

Fix in nqp to set $*SUPPOSING: e0e113dcbf0e02ab8b22216521ea74f18f6a1bef

Fix in rakudo to make use of $*SUPPOSING to suppress thunk refs: 
9c7b3c1f47622b0751f3752f52d93e257cc4b8d5

I'm resolving this, but someone can still write a test if they can figure out 
how...  :)

Reply via email to