Skip to content

Needs documentation for the runtime JS shims in tessel/runtime #15

@paulcuth

Description

@paulcuth

Hi,

I'm currently looking at using Colony outside of the Tessel ecosystem and I'm unable to output working Lua code.

For example, if we execute the following JavaScript in Node...

var fs = require('fs'),
    compiler = require('colony-compiler'),
    source = "function sum(a,b){return a+b;} module.exports = {sum:sum};";

fs.writeFile ('output.lua', compiler.colonize(source).source);

... it outputs the following Lua in output.lua (module wrapping omitted)...

local sum = sum;
sum = (function () local sum = nil; sum = function (this, a, b)
--[[18]] if true then return ((a)+(b)); end
end; sum.name = "sum"; return sum; end)();
--[[0]] 
--[[31]] module.exports = _obj({
  ["sum"]=sum
});

This fails to run in Lua 5.1, 5.2 and LuaJIT because it tries to add a name property to a function. It produces the following error:

lua: ./output.lua:10: attempt to index local 'sum' (a function value)

Is this expected behaviour? Am I using different versions of Lua than you? Do you have a custom build of Lua where adding properties to functions is allowed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions