Neat-Lang / neat

The Neat Language compiler. Early beta?
BSD 3-Clause "New" or "Revised" License
111 stars 9 forks source link

Confusing error caused by `return` without a semicolon #28

Closed dbohdan closed 1 year ago

dbohdan commented 1 year ago

Compiling the following code results in this error: "Assertion failed! Aborting."

module ret;

void main() {
    return
}

The problem with the code is that the semicolon is missing after the return statement, which does not have an argument. The code compiles without the semicolon when return has an argument.

// Compiles.
module ret;

int main() {
    return 0
}

The compiler should say the error is due to invalid syntax.

Edit: Oops, I misdiagnosed the cause of the error at first. Fixed.

FeepingCreature commented 1 year ago

Thanks! Fixed.

It's a bit weird to parse because return is an expression, not a statement.

FeepingCreature commented 1 year ago

Error message is now:

hello.nt:3:
void main() { return }
                     ^ expression or semicolon expected