Skip Menu |
Report information
Id: 125684
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: alex.jakimenko [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Alex Jakimenko <alex.jakimenko [...] gmail.com>
Subject: LTA error message when using invalid characters in number literals
To: rakudobug [...] perl.org
Date: Sat, 25 Jul 2015 01:53:37 +0300
Download (untitled) / with headers
text/plain 541b
Code:
say 0b000l01;

Result:
===SORRY!=== Error while compiling ./test.pl
Confused
at ./test.pl:2
------> say 0b000⏏l01;

The error message could be better. For example:
Code:
say :2<000l01>;

Result:
===SORRY!===
Invalid character 'L' in number literal

It would be great (if it is easy to implement) if it also mentioned that it is a hex/binary/octal number (not just a number literal), because some people might be unaware of that notation (kid-friendly error messages?).

IRC log: http://irclog.perlgeek.de/perl6/2015-07-24#i_10951220
FWIW, here was my attempt to resolve this issue:

diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp
index 13c09feb9..09b05bac7 100644
--- a/src/Perl6/Grammar.nqp
+++ b/src/Perl6/Grammar.nqp
@@ -3553,6 +3553,9 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
         | <VALUE=decint>
         ]
         <!!before ['.' <?before \s | ',' | '=' | ':' | <.terminator> | $ > <.typed_sorry: 'X::Syntax::Number::IllegalDecimal'>]? >
+        [ :my $inv; <?before $<a>=<:L - [ei]> { $inv := $<a> }>
+                    <.typed_panic: "X::Syntax::Confused",
+                     reason => "Invalid character '$inv' in number literal"> ]?
         [ <?before '_' '_'+\d> <.sorry: "Only isolated underscores are allowed inside numbers"> ]?
     }
 

This made the error message as awesome as it was suggested in the OP. Problem is, some spectests were failing. Things like :42foo started to complain needlessly. I guess it's still possible to resolve this ticket, I was simply doing it wrong.

On 2015-07-24 15:53:57, alex.jakimenko@gmail.com wrote:
Show quoted text
> Code:
> say 0b000l01;
>
> Result:
> ===SORRY!=== Error while compiling ./test.pl
> Confused
> at ./test.pl:2
> ------> say 0b000⏏l01;
>
> The error message could be better. For example:
> Code:
> say :2<000l01>;
>
> Result:
> ===SORRY!===
> Invalid character 'L' in number literal
>
> It would be great (if it is easy to implement) if it also mentioned that it
> is a hex/binary/octal number (not just a number literal), because some
> people might be unaware of that notation (kid-friendly error messages?).
>
> IRC log: http://irclog.perlgeek.de/perl6/2015-07-24#i_10951220




This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org