neolithos / neolua

A Lua implementation for the Dynamic Language Runtime (DLR).
https://neolua.codeplex.com/
Apache License 2.0
467 stars 76 forks source link

Nesting of [[ ... ]] should produce error #105

Open thoj opened 4 years ago

thoj commented 4 years ago

NeoLua Version: 13.11

Example to reproduce:

local longstr = [[Show me this
yes!
]]

--[[

local unused_string = [[Line1
Line2]]

local longstr = [[
Do not show me this
Multiline string]]

--]]

print(longstr)

Hi i ran into this when i used

--[[ Some code something = [[ long string ]] Some Code <-- this executed --]] Some more code

I got really confused until i tried with normal lua interpeter where i got: lua: [string ""]:5: nesting of [[...]] is deprecated near '['

I think NeoLua also should make nesting [[...]] an error.

Note for others: You should enclose long strings in [=[...]=], [==[...]==], [===[...]===], etc to avoid this.

neolithos commented 4 years ago

I always test with: Lua Live Demo And it produces the same result as NeoLua.

The reason is you commented the last closing string out. For the neolua the whole line is a comment.

What lua-interpreter did you use? Version?

thoj commented 4 years ago

Weird. I tried with Lua 5.1.5 and got the above deprecated message.

tj@ami:~$ lua test.lua
lua: test.lua:7: nesting of [[...]] is deprecated near '['
tj@ami:~$ lua -v
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
tj@ami:~$ lua5.3 test.lua
Do not show me this
Multiline string

Strange that lua would let you shoot yourself in the foot like that without even a warning.

neolithos commented 4 years ago

Interesting...

I have no idea, which way is the best?

thoj commented 4 years ago

Hmm yeah this is a quite interesting issue. The best in my opinion would be a warning.