You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.jakimenko@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:
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.
p6rt
added
the
LTA
Less Than Awesome; typically an error message that could be better
label
Jan 5, 2020
Migrated from rt.perl.org#127856 (status was 'new')
Searchable as RT127856$
The text was updated successfully, but these errors were encountered: