Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
thoj opened this issue Oct 2, 2019 · 4 comments
Open

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

thoj opened this issue Oct 2, 2019 · 4 comments

Comments

@thoj
Copy link
Contributor

thoj commented Oct 2, 2019

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
Copy link
Owner

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
Copy link
Contributor Author

thoj commented Oct 4, 2019

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
Copy link
Owner

Interesting...

I have no idea, which way is the best?

@thoj
Copy link
Contributor Author

thoj commented Oct 4, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants