Skip to content

Fix: unwrap multi-return values in PropertyAccess and method calls#1895

Merged
zefhemel merged 1 commit intosilverbulletmd:mainfrom
anb:lua-eval-property-singleresult
Mar 18, 2026
Merged

Fix: unwrap multi-return values in PropertyAccess and method calls#1895
zefhemel merged 1 commit intosilverbulletmd:mainfrom
anb:lua-eval-property-singleresult

Conversation

@anb
Copy link
Copy Markdown
Contributor

@anb anb commented Mar 18, 2026

evalPrefixExpression can return a LuaMultiRes (e.g. string.gsub returns (result, count)).

The TableAccess case already called singleResult() to unwrap this, but PropertyAccess and the method-call path in FunctionCall did not — causing "attempt to index a userdata value" when chaining on multi-return results.

This adds the missing singleResult() calls to match Lua's adjustment rules for single-value contexts.

I discovered this when adding support for https://fennel-lang.org . The fennel compiler, written in Lua, mostly works in your lua implementation, except for this issue (and Lezer doesn't handle parsing the fennel compiler source very well but that's out of scope of this PR)

@zefhemel
Copy link
Copy Markdown
Collaborator

Nice catch

@zefhemel zefhemel merged commit 4045e92 into silverbulletmd:main Mar 18, 2026
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants