Hi,
Perhaps the error is caused by the assignment wanting to store 42 at the
address of $test, which is not there yet. See also doc about 'sub () is rw
{ ••• }'. Look for rw traits!
Furthermore, to declare and assign more variables use
(my $a, my $b) = ( 42, 43);
Greetings
Marcel
On April 8, 2016 1:29:52 AM Alex Jakimenko (via RT)
<perl6-bugs-follo...@perl.org> wrote:
# New Ticket Created by Alex Jakimenko
# Please include the string: [perl #127856]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=127856 >
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.