Basically, this would need to throw X::Syntax::KeywordAsFunction, but it blows up when trying to look up $test so that's rather unfortunate. Pretty sure we can do something about it but maybe it's not a one-line fix.
On 2016-04-07 16:29:37, alex.jakime...@gmail.com wrote: > Code: > my($test) = 42 > > Result: > ===SORRY!=== Error while compiling -e > Variable '$test' is not declared > at -e:1 > ------> my(⏏$test) = 42 > > > Sure enough $test is not declared, I am trying to declare it! > > This error message is especially sad considering that this is allowed: > > Code: > my$test = 42; > > Result: > (no output, everything works correctly) > > > And of course, it is always interesting to see real life examples of > people struggling with an LTA error: > http://irclog.perlgeek.de/perl6/2016-04-07#i_12303463 > > The reason why my() is not allowed is probably exactly the same as the > reason why we don't have if(), but at least in the latter case provide > a meaningful error message. Let's take a look at what happens if you > try to use if(): > > Code: > if(1) {} > > Result: > ===SORRY!=== > Word 'if' interpreted as 'if()' function call; please use whitespace > instead of parens > at -e:1 > ------> if⏏(1) {} > Unexpected block in infix position (two terms in a row) > at -e:1 > > > Well, we should not say that the user should use whitespace instead of > parens (maybe he/she is trying to declare multiple variables), but we > should definitely say how it is interpreted and that a space between > the parens and “my” will solve the problem.