Closed sig11b closed 9 months ago
Verified in the latest source. Thanks!
Yeah, that's invalid syntax. You want give hall ~on;
with no parens.
Similar errors occur for:
val = (2~1);
val = ((2)~1);
val = (2 ~~ 1);
But not:
val = 2~1; ! invalid but produces a sensible error
val = ~1; ! valid, bitwise not
val = (~1); ! ditto
While we're looking at prefix/postfix unary operators:
val = (1 -- 2);
val = (1 ++ 2);
...both produce:
line 7: Compiler error: SR error: Attempt to remove a nonexistent bracket layer from the emitter stack line 7: Compiler error: SR error: emitter stack overfull in subexpression line 7: Compiler error: SR error: Attempt to remove a nonexistent bracket layer from the emitter stack line 7: Compiler error: SR error: emitter stack overfull
My current thinking about this:
If you write (1 2)
as an expression, the compiler correctly diagnoses this as two expressions with no operator between them:
Error: Missing operator: inserting '+'
("Inserting '+'" is just a way to continue compiling the line. I think I want to remove those words from the error; it's just confusing to the user.)
Writing (1 ~2)
or (1 ++x)
is the same mistake, but the compiler fails to recognize it. So that's the check I want to add. Haven't figured out where to add it yet.
Of course the trick is that (1-2)
is not a mistake, because -
is both a unary and binary operator.
More troubling: the expression (x++-1)
, which should be valid, also produces an internal compiler error!
Without the parens, it produces (not-internal) error: "Expected ';' but found -".
Written (x++)-1
, it works correctly.
EDIT-ADD: It looks like the compiler is treating the -
as unary in this expression. That's why it thinks the expression is invalid. This is wrong, but it's an unrelated error and not one I'm very worried about. I'm just going to handle the internal compiler error issue.
I received a compiler error, and the error message asked me to submit a bug report. So here it goes. I could boil it down to a tiny story which still produces the error. I'm pretty sure, that this is some sort of illegal syntax, but that's what I accidentally typed. The offending line is
give (hall ~on);
and here the full story:
This is what I got: