wasmoon icon indicating copy to clipboard operation
wasmoon copied to clipboard

Default null to nil when injectObjects is not set

Open gudzpoz opened this issue 11 months ago • 0 comments

The PR #101 handles null values only when injectObjects is set to true. When injectObjects is undefined or false, null values are not handled at all, somehow triggering a TypeError in PromiseTypeExtension or otherwise a The type 'object' is not supported by Lua error.

const { LuaFactory } = require('wasmoon')
const L = await factory.createEngine({ injectObjects: false })
L.global.pushValue(null) // TypeError here
Uncaught TypeError: Cannot read properties of null (reading 'then')
    at PromiseTypeExtension.pushValue (.../node_modules/.pnpm/[email protected]/node_modules/wasmoon/dist/index.js:916:102)
    at .../node_modules/.pnpm/[email protected]/node_modules/wasmoon/dist/index.js:244:82
    at Array.find (<anonymous>)
    at Global.pushValue (.../node_modules/.pnpm/[email protected]/node_modules/wasmoon/dist/index.js:244:46)

This PR adds a simple DefaultNullTypeExtension for cases when injectObjects is false.

fixes #104

gudzpoz avatar Mar 22 '24 16:03 gudzpoz