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

Ensure that lua 5.3 is supported #124

Closed
wilhelmy opened this issue Jun 21, 2019 · 9 comments · Fixed by #127
Closed

Ensure that lua 5.3 is supported #124

wilhelmy opened this issue Jun 21, 2019 · 9 comments · Fixed by #127
Labels
Lua 5.3 Issues with Lua 5.3 compatibility Lua 5.4 Issues with Lua 5.4 compatibility

Comments

@wilhelmy
Copy link
Collaborator

/usr/local/bin/notion: ioncore_misc.lua:77: attempt to call a nil value (global 'unpack')

It seems the unpack() function was removed. Maybe there's more.

@wilhelmy
Copy link
Collaborator Author

Some wisdom from the internet: "In Lua 5.2, unpack was moved to table.unpack."

So I guess sprinkling about some local unpack = unpack or table.unpack should do the trick.

I might look into it.

knixeur pushed a commit to knixeur/notion that referenced this issue Jun 21, 2019
knixeur added a commit to knixeur/notion that referenced this issue Jun 21, 2019
@wilhelmy
Copy link
Collaborator Author

I think that wasn't it.

https://www.lua.org/pil/5.2.html

unpack() in this case is used to unpack "arg", I think they changed the way variable arguments work in Lua 5.3. Since "arg" on the global level is also what argv is in C, this introduces additional confusion — I've seen command line arguments show up in unexpected places.

@wilhelmy
Copy link
Collaborator Author

Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio
> function foo(...)
>> return arg
>> end
> foo(1,2,3)
table: 0x5579dc40b430
> foo(1)
table: 0x5579dc40b430
> foo(1)[0] -- argv[0]
lua5.3


Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> function foo(...)
>> return arg
>> end
> =foo(1,2,3)[0] -- lua table (i.e. not argv), 1-indexed
nil
> =foo(1,2,3)
table: 0x56228a2c3d20

I think we should make sure that 5.3 doesn't introduce unexpected breakage anywhere else.

@wilhelmy
Copy link
Collaborator Author

In both 5.3 as well as 5.1 you can access the arguments via "...", but I'm not sure that still works in 5.0 (maybe we can deprecate 5.0, it's from 2003-2006)

@wilhelmy
Copy link
Collaborator Author

https://www.lua.org/manual/5.0/manual.html#2.5.8 Ctrl+F variadic

Compare that to

https://www.lua.org/manual/5.1/manual.html#2.5.8 Ctrl+F variadic

Seems to me they replaced the implicit "arg" parameter by the new "..." form of accessing the arguments, but kept arg for compatibility reasons.

@wilhelmy
Copy link
Collaborator Author

Lua 5.0  Copyright (C) 1994-2003 Tecgraf, PUC-Rio
> function foo(...)
>> return ...
stdin:2: unexpected symbol near `...'

yup, seems that way.

@knixeur knixeur reopened this Jun 22, 2019
@knixeur
Copy link
Collaborator

knixeur commented Jun 22, 2019

https://www.lua.org/manual/5.1/manual.html#7.1

Migrations have been done to comply with new format for example b2b1755 but this is >=5.1, I think dropping support for 5.0 will make our lives easier.

@raboof
Copy link
Owner

raboof commented Jun 22, 2019

I agree we should drop support for Lua 5.0 and start requiring Lua 5.1. Even though Debian still ships lua50 it also has newer versions.

@wilhelmy
Copy link
Collaborator Author

I'm also in favour of dropping 5.0 because there is no workaround for this other than preprocessing the lua code (yikes), because using ... in 5.0 results in a syntax error.

I've just checked, Lua has preview releases for 5.4, and there seems to be nothing incompatible this time: https://www.lua.org/work/doc/manual.html#8

wilhelmy added a commit to wilhelmy/notion that referenced this issue Jun 22, 2019
Variadic functions were introduced in 5.0, but the method of accessing
them changed in 5.1. This makes the code incompatible with 5.0 (it is
already incompatible since at least b2b1755), which will be removed
from the build system in a subsequent commit.

Fixes raboof#124. See also raboof#90.
@raboof raboof closed this as completed in 7f0d1d8 Jun 23, 2019
@wilhelmy wilhelmy added Lua 5.3 Issues with Lua 5.3 compatibility Lua 5.4 Issues with Lua 5.4 compatibility labels Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Lua 5.3 Issues with Lua 5.3 compatibility Lua 5.4 Issues with Lua 5.4 compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants