# New Ticket Created by Alex Jakimenko
# Please include the string: [perl #126008]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=126008 >
Code:
my Int $x = 5;
my Str $x = 'hello';
Result:
Potential difficulties:
Redeclaration of symbol $x
at ./test.pl:3
------> my Str $x⏏ = 'hello';
Type check failed in assignment to '$x'; expected 'Str' but got 'Int'
in block <unit> at ./test.pl:2
While compile-time “potential difficulties” part totally makes sense,
run-time error is confusing. “got 'Int'” is weird, because I gave it a Str.
You might think that using an integer can help:
my Int $x = 5;
my Str $x = 10;
Result:
Potential difficulties:
Redeclaration of symbol $x
at ./test.pl:3
------> my Str $x⏏ = 10;
Type check failed in assignment to '$x'; expected 'Str' but got 'Int'
in block <unit> at ./test.pl:2
In other words, it is exactly the same error… And not only you cannot
assign anything, but you cannot even declare it:
my Int $x = 5;
my Str $x;
Result:
Potential difficulties:
Redeclaration of symbol $x
at ./test.pl:3
------> my Str $x⏏;
Type check failed in assignment to '$x'; expected 'Str' but got 'Int'
in block <unit> at ./test.pl:2
It looks totally less than awesome for me. Interestingly, if it was a
compile-time death, it would have been less LTA.