Skip to content

unable to remove keys from hashes after interop #82

@TomWoodward

Description

@TomWoodward

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 wasmoon@1.15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions