daurnimator / lua.vm.js

The project is superceded by Fengari. See https://fengari.io/
MIT License
835 stars 101 forks source link

Off by one error in argument passing to Javascript #53

Closed vadi2 closed 8 years ago

vadi2 commented 8 years ago

Test case:

function test(a,b) {console.log(a); console.log(b);};
test("a", "b");
VM1485:1 a
VM1485:1 b
undefined
L.execute("js.global.test('a', 'b')");
VM1485:1 b
VM1485:1 undefined
[]
L.execute("js.global.test(nil, 'a', 'b')");
VM1485:1 a
VM1485:1 b
[]
daurnimator commented 8 years ago

The first argument passed to a js function is used as this. In most cases, just use the lua method call syntax:

L.execute("js.global:test('a', 'b')");

(Yes we need to write documentation about js <=> lua semantics)