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

Failure chaining function call and table accesses #13

Closed
jeff-emanuel opened this issue May 4, 2018 · 6 comments
Closed

Failure chaining function call and table accesses #13

jeff-emanuel opened this issue May 4, 2018 · 6 comments

Comments

@jeff-emanuel
Copy link

This code works in Lua 5.3.4:

Lua 5.3.4 Copyright (C) 1994-2017 Lua.org, PUC-Rio

function A() return {"a",{X="x"}} end
print(A()[2].X)
x

Here the X access yields nil, but it works when using an intermediate variable such as:

function A() return {"a",{X="x"}} end
u=A()[2]
print(u.X)
x

See attached code.
luatablefunction.zip

@milochristiansen
Copy link
Owner

Sounds like yet another compiler bug. I'll check it out tonight.

@jeff-emanuel
Copy link
Author

Thanks

@milochristiansen
Copy link
Owner

milochristiansen commented May 4, 2018

OK, I confirmed it to be a compiler error, the generated code is inexplicably missing the instruction to do the first index operation (the [2] part), although it generates everything else correctly. I as of yet do not know why it is missing this bit, but it shouldn't be too hard to track it down.

I'll have a fix up soon, AKA within a few hours of me waking up tomorrow (I'm a bit tired right now).

Honestly, I was sure I had all the stupid little edge case bugs squashed long ago, but it seems the compiler is the gift that keeps on giving :P In any case, I am grateful for every bug that is reported, each one found and fixed makes the package just a little bit better.

@milochristiansen
Copy link
Owner

OK, so this is proving harder than expected. Normally finding the issue is pretty easy, and fixing it is the "hard" part. This time I'm having trouble identifying what is causing the issue. I'll get it sooner or later, but not as soon as I expected. Sorry.

@milochristiansen
Copy link
Owner

Tests pass, and the example provided works. The bug would probably also effect expressions in parenthesis followed by table accessors, not just function calls followed by accessors, but both should work now.

Once I figured out where the problem was fixing it was pretty trivial, just as expected.

@jeff-emanuel
Copy link
Author

It works great. Thanks so much!

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

No branches or pull requests

2 participants