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

unable to remove keys from hashes after interop #82

Open
TomWoodward opened this issue Jun 23, 2023 · 4 comments
Open

unable to remove keys from hashes after interop #82

TomWoodward opened this issue Jun 23, 2023 · 4 comments

Comments

@TomWoodward
Copy link

in a normal lua environment, my understanding is that the normal way to remove a key from a hash is to set its value to nil, like this:

lua -e "obj={print_me='foobar',dont_print_me='foobar'}; obj.dont_print_me=nil; for k,v in pairs(obj) do print(k); end"

prints only the one key

in wasmoon it works the same with no interop

node << EOF
new (require("wasmoon").LuaFactory)().createEngine().then(lua => lua.doString("obj={print_me='asdf',dont_print_me='asdf'}; obj.dont_print_me=nil; for k,v in pairs(obj) do print(k); end"));
EOF

prints only the one key

but if i interop at all with js i get both keys

node << EOF
new (require("wasmoon").LuaFactory)().createEngine().then(lua => { lua.global.set('identity', x => x); lua.doString("obj=identity({print_me='foobar',dont_print_me='foobar'}); obj.dont_print_me=nil; for k,v in pairs(obj) do print(k); end") });
EOF

gets both keys

i'm experiencing a bunch of bugs because in normal code you never expect looping over pairs to return null values, but with wasmoon it does in this case. is there something i can do to fix this?

using [email protected]

@ceifa
Copy link
Owner

ceifa commented Jul 4, 2023

Hey, can you try disable enableProxy and check if the issue persists?

@TomWoodward
Copy link
Author

looks like that does fix it

node << EOF
>  new (require("wasmoon").LuaFactory)().createEngine({enableProxy:false}).then(lua => { lua.global.set('identity', x => x); lua.doString("obj=identity({print_me='foobar',dont_print_me='foobar'}); obj.dont_print_me=nil; for k,v in pairs(obj) do print(k); end") });
> EOF
print_me

i saw some other issues mentioning these config options, but no documentation describing what they do. is there some somewhere?

@TomWoodward
Copy link
Author

TomWoodward commented Jul 11, 2023

closing because the enableProxy:false was the solution here, but i would suggest some more documentation for these options.

also, you might consider disabling the proxy by default, because it really causes some issues in otherwise valid LUA code

@ceifa
Copy link
Owner

ceifa commented Jul 11, 2023

i saw some other issues mentioning these config options, but no documentation describing what they do. is there some somewhere?

No, I'm very bad at documenting (PRs welcome)

also, you might consider disabling the proxy by default, because it really causes some issues in otherwise valid LUA code

Actually I think this issue specifically can be a bug and not a expected behaviour of proxying. I will reopen to check this later.

@ceifa ceifa reopened this Jul 11, 2023
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