parser: now checks whether the assign operator '=' is preceded by a variable

This commit is contained in:
2024-03-31 06:38:46 +02:00
parent 28e3b2f741
commit f58ec3ac32
2 changed files with 11 additions and 0 deletions
+3
View File
@@ -128,6 +128,9 @@ func TestParser(t *testing.T) {
/* 101 */ {`false or (x==2)`, nil, errors.New(`undefined variable "x"`)},
/* 102 */ {`a=5; a`, int64(5), nil},
/* 103 */ {`a=5; b=2; add(a, b*3)`, int64(11), nil},
/* 104 */ {`2=5`, nil, errors.New(`assign operator ("=") must be preceded by a variable`)},
/* 105 */ {`2+a=5`, nil, errors.New(`left operand of "=" must be a variable`)},
/* 106 */ {`2+(a=5)`, int64(7), nil},
}
succeeded := 0
failed := 0