mojo
mojo copied to clipboard
[BUG] Spurious error generated for faulty `for` statement
Bug description
As title. Couldn't think of a better one, sorry.
Steps to reproduce
fn f():
for i in range(a):
...
Error message looks like the following:
workspaces/ubuntu/bug.mojo:2:18: error: use of unknown declaration 'a', 'fn' declarations require explicit variable declarations
for i in range(a):
^
/workspaces/ubuntu/bug.mojo:2:20: error: unexpected token in expression
for i in range(a):
^
/workspaces/ubuntu/bug.mojo:2:20: error: statements must start at the beginning of a line
for i in range(a):
^
/home/vscode/.modular/pkg/packages.modular.com_mojo/bin/mojo: error: failed to parse the provided Mojo
The error "unexpected token" can be really confusing because it appears to indicate that there is a syntax error.
System information
Mojo 24.2 on Docker, Intel Mac