LivelyKernel / lively.ast

Parsing JS code into ASTs and tools to query and transform these trees.
4 stars 0 forks source link

lively.ast.parseFunction: Uncaught (in promise) TypeError: visitor[(override || node.type)] is not a function #7

Closed JensLincke closed 8 years ago

JensLincke commented 8 years ago

when using livley.ast

lively.ast.parseFunction("function() { 3 + 4}")

We got an error:

lively.modules-with-lively.vm.js:9524 Uncaught (in promise) TypeError: visitor[(override || node.type)] is not a function
    at c (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:9524:35)
    at Object.recursive (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:9525:5)
    at forEachNode (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:18234:10)
    at addSource (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:18293:12)
    at Object.parseFunction (https://lively-kernel.org/lively4/lively4-jens/src/external/lively.modules-with-lively.vm.js:18832:32)

By not using "addSource" we got rid of the error... what does it do?


lively.ast.parseFunction =  function parseFunction(source, options) {
    var src = '(' + source + ')',
        ast = lively.ast.parse(src, options);
    // /*if (options.addSource) */addSource(ast, src);
    return ast.body[0].expression;
  }
JensLincke commented 8 years ago

we should remove the monkey patch in https://lively-kernel.org/lively4/lively4-jens/start.html?edit=https://lively-kernel.org/lively4/lively4-jens/src/client/patches.js when this issue is fixed