On Sat, Mar 26, 2005 at 03:32:18PM +1100, Andrew Savige wrote: : I stumbled across a couple of interesting quote interpolation : edge cases: : : Case 1 : ------ : : # cat ttt.p6 : my $x = "{"; : : # pugs ttt.p6 : : unexpected end of input : expecting "\"", "$!", "$/", "\\" or block : NonTerm SourcePos "ttt.p6" 2 1 : : Is this a bug?
No, but it could probably use a better error message about a possible runaway closure in the string, much as Perl 5 warns about runaway strings. : Case 2 : ------ : : # cat q1.pl : my $x = "$"; : print "x='$x'\n"; : : # perl -w q1.pl : Final $ should be \$ or $name at q1.pl line 1, within string : syntax error at q1.pl line 1, near "= "$"" : Execution of q1.pl aborted due to compilation errors. : : # pugs q1.pl : x='$' : : Wow, is pugs better than p5 here? ;-) Well, yes, actually. Perl 5 manages to catch the error only because it does bogus terminator-parsing lookahead. Pugs ought to have got a syntax error on the backslash, I think, and reported a runaway quote as the likely cause. Though in fact, with a backtracking parser you should be able to determine the point at which a different decision would have produced a successful parse. We shouldn't generate code from the successful parse once we're in error state, but it could give us much better diagnostics in certain cases if we install backtracking decision points for things that look suspiciously like they meant something else. In this particular case the parser could have intuited exactly what went wrong. Hmm, well, if it got that far. Given strict being on by default, this particular example should probably just die on the fact that $" isn't declared, since there's no $" in Perl 6. Larry