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 a semicolon is missing before a while loop (my $x = 5 while True {}) #5852

Open
p6rt opened this issue Dec 3, 2016 · 4 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Dec 3, 2016

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

Searchable as RT130251$

@p6rt
Copy link
Author

p6rt commented Dec 3, 2016

From @AlexDaniel

Code​:
my $x = 5

while True {
}

Result​:
===SORRY!=== Error while compiling -e
Unexpected block in infix position (missing statement control word before the expression?)
at -e​:3
------> while True⏏ {
  expecting any of​:
  infix
  infix stopper

So it is parsed as a statement modifier, that's fine, but the problem is that the error message is way off whet it trips over a block. “Did you forget a semicolon on the previous line?” would be a good addition, but we'd need some heuristic for that.

@p6rt
Copy link
Author

p6rt commented Dec 5, 2016

From mefzz@cpan.org

On Sat, 03 Dec 2016 07​:51​:07 -0800, alex.jakimenko@​gmail.com wrote​:

Code​:
my $x = 5

while True {
}

Result​:
===SORRY!=== Error while compiling -e
Unexpected block in infix position (missing statement control word
before the expression?)
at -e​:3
------> while True⏏ {
expecting any of​:
infix
infix stopper

So it is parsed as a statement modifier, that's fine, but the problem
is that the error message is way off whet it trips over a block. “Did
you forget a semicolon on the previous line?” would be a good
addition, but we'd need some heuristic for that.

This is a good suggestion, I would say. The error information is a bit complex for a very simple semicolon missing.
--
'There is only two types of testing. One, a testing by the developer. Two, a
testing by the end user.

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
@uchuugaka
Copy link

Well, I have hit the same thing forgetting a semicolon with the first example code in Morris Lentz' book, Raku Fundamentals : A Primer with Examples, Projects, and Case Studies, and this is an especially devilish error if one is also often working with languages that do not require semicolons to end statements.

I had

# file sudoku.p6
use v6.d;

my $sudoku = '000000075000080094000500600010000200000900057006003040001000023080000006063240000'
for 0..8 -> $line-number {
  say substr $sudoku, $line-number * 9, 9;
}

but should have had

# file sudoku.p6
use v6.d;

my $sudoku = '000000075000080094000500600010000200000900057006003040001000023080000006063240000';
for 0..8 -> $line-number {
  say substr $sudoku, $line-number * 9, 9;
}

And yeah, it returned

% raku sudoku.p6 
===SORRY!=== Error while compiling /Users/john.joyce/Documents/Programming/Perl 6/Raku/sudoku.p6
Unexpected block in infix position (missing statement control word before the expression?)
at ~/path/to/sudoku.p6:5
------> for 0..8⏏ -> $line-number {
    expecting any of:
        infix
        infix stopper

@uchuugaka
Copy link

Fits the very definition of LTA!!!

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

2 participants