Log In  


It seems that the parser treats “=” and “+=” slightly differently in this snippet:

x=rnd();print(x)  -- ok
x=rnd() print(x)  -- ok
x=rnd()print(x)   -- ok
x+=rnd();print(x) -- ok
x+=rnd() print(x) -- ok
x+=rnd()print(x)  -- runtime error


actually it's worse than that!
the next character is mangled:

x=1
x+=5qq=2 -- parsed as x+=5 q=2
print(qq)
print(q)

runs fine and prints nil 2 (instead of 2 nil)


Guys, just add a space where it's needed ! :D


Here’s another simple one that gives a syntax error:

x
+=1

a line end is a statement end
x;
+=1;


That's not true at all.

i=
3

i=1+
2

i=1
+2

i
=3

All valid code



[Please log in to post a comment]