-
Notifications
You must be signed in to change notification settings - Fork 171
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
a=1; -a
returns an invalid value
#568
Comments
I have an idea to fix the issue: how about changing func (l *Lexer) skipWhitespace() {
for l.ch == ' ' || l.ch == '\t' || l.ch == '\r' || l.ch == '\n' || l.ch == ';' {
if l.ch == '\n' || l.ch == ';' {
l.line++
}
l.readChar()
}
} |
I think this is just a workaround, not the best solution |
It looks like when the unary operator is present, these are being treated as » a="1";.to_i
#» 1 |
Can you help me confirm this as well? |
Got it! |
I know the test below is incorrect, but the result below should be clear on how it was parsed: // parser_test.go
func TestMultipleExpressionOnSameLineParsing(t *testing.T) {
tests := []struct {
input string
expected string
}{
{
"a = 1; +a",
"a = 1; +a",
},
{
"a = 1; .to_i",
"a = 1; .to_i",
},
}
// ... omit The result:
(However, I'm still thinking about how should the problem be solved. 🤔 ) |
@Maxwell-Alexius great observation! According to the failure message, I think the parser just ignored the semicolon accidentally. |
Found the issue in #560, on REPL.
Unary operator
+
or-
just after semicolon;
returns invalid values like:The text was updated successfully, but these errors were encountered: