Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error message when using invalid characters in number literals (say 0b000l01) #4439

Open
p6rt opened this issue Jul 24, 2015 · 2 comments
Open
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Jul 24, 2015

Migrated from rt.perl.org#125684 (status was 'new')

Searchable as RT125684$

@p6rt
Copy link
Author

p6rt commented Jul 24, 2015

From @AlexDaniel

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

@p6rt
Copy link
Author

p6rt commented Oct 7, 2017

From @AlexDaniel

FWIW, here was my attempt to resolve this issue​:

Inline Patch
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​:

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

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant