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
P#29251 2016-09-24 04:59 ( Edited 2016-09-27 21:39)

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)

P#29253 2016-09-24 07:17 ( Edited 2016-09-24 13:13)

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

P#29274 2016-09-24 11:41 ( Edited 2016-09-24 15:41)

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

x
+=1
P#29318 2016-09-24 17:13 ( Edited 2016-09-24 21:13)

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

P#29521 2016-09-27 17:21 ( Edited 2016-09-27 21:21)

That's not true at all.

i=
3

i=1+
2

i=1
+2

i
=3

All valid code

P#29522 2016-09-27 17:39 ( Edited 2016-09-27 21:40)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 15:05:14 | 0.008s | Q:24