in reply to Re: BUG when parsing defined-or ?
in thread BUG when parsing defined-or ?

That was my first idea too ...

... but I think something is fundamentally broken with the parsing of prototyped sub calls.

see how + fails ...

lanx@lanx-1005HA:/tmp$ perl -MO=Deparse -e 'sub foo (&) {}; foo {"foo" +} + 3' Too many arguments for main::foo at -e line 1, at EOF -e had compilation errors. sub foo (&) { } &foo(sub { 'foo'; } , 3);
... while . works
lanx@lanx-1005HA:/tmp$ perl -MO=Deparse -e 'sub foo (&) {}; foo {"foo" +} . "3"' sub foo (&) { } foo(sub { 'foo'; } ) . '3'; -e syntax OK

Seems like the parser tries to guess if a second parameter follows even if no further parameters are allowed.

The + fails because it's also a unary operator, so the foo( BLOCK, +3 ) interpretation is preferred, but later rejected, without backtracking into another, binary interpretation.

I'm no expert of how the lexer works but implementing parsing on such heuristics is a fragile thing.

Hopefully this can be fixed in the future.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

update

that's really a depressing bug, I had much hope in using more block prototypes.