Log In  

This code does not work (unexpected symbol near 'then'):
if (x == "\\") then print(x) end

But this works OK:
bs = "\\" if (x == bs) then print(x) end

P#59713 2018-12-05 14:31

Tried fiddling a bit to see if I could repro on my machine...

This first one executes correctly (prints "char 7 is \"), but the syntax-highlighter thinks that the "then" keyword and the print statement's closing parenthesis are contained inside of the strings on their lines:

if char=="\" then

This one fails to execute:

if (char=="\") then

It seems like under "certain conditions" in the pipeline, the second backslash is still getting viewed as if it was an escape-character, and that's somehow "half-escaping" the ending quote mark. Very strange that the highlighter and the actual code parser are getting different results like that!

Snippet if you wanna try other variations:

x="hello \\"

for i=1,#x do
    if char=="\\" then
        print("char "..i.." is \\")
P#59716 2018-12-05 16:08 ( Edited 2018-12-05 16:09)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-08-15 11:15 | 0.008s | 4194k | Q:12