-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
I am trying to walk an AST parsed with the stage3 plugin, but both the injector and the decorated acorn instance throw an error.
The following code:
const acorn = require("acorn-stage3");
const walk = require("acorn/dist/walk");
const content = `
import("./module.js");
test("foo");
`;
const parsed = acorn.parse(content, { sourceType: 'module', plugins: { stage3: true } });
walk.simple(parsed, {
CallExpression(node) { console.log(node) }
});
Will throw an error like:
TypeError: baseVisitor[type] is not a function
at c (/private/tmp/prova/node_modules/acorn/dist/walk.js:29:22)
at Object.skipThrough (/private/tmp/prova/node_modules/acorn/dist/walk.js:183:37)
at c (/private/tmp/prova/node_modules/acorn/dist/walk.js:29:22)
at Object.base.NewExpression.base.CallExpression (/private/tmp/prova/node_modules/acorn/dist/walk.js:374:3)
at c (/private/tmp/prova/node_modules/acorn/dist/walk.js:29:22)
at Object.skipThrough (/private/tmp/prova/node_modules/acorn/dist/walk.js:183:37)
at c (/private/tmp/prova/node_modules/acorn/dist/walk.js:29:22)
at Object.base.ExpressionStatement.base.ParenthesizedExpression (/private/tmp/prova/node_modules/acorn/dist/walk.js:201:35)
at c (/private/tmp/prova/node_modules/acorn/dist/walk.js:29:22)
at Object.skipThrough (/private/tmp/prova/node_modules/acorn/dist/walk.js:183:37)
>
Using the injector will yield equal results:
const acorn = require("acorn");
const walk = require("acorn/dist/walk");
const injectAcornStage3 = require("acorn-stage3/inject");
const localAcorn = injectAcornStage3(acorn);
const content = `
import("./module.js");
test("foo");
`;
const parsed = localAcorn.parse(content, { sourceType: 'module', plugins: { stage3: true } });
console.log(parsed);
walk.simple(parsed, {
CallExpression(node) { console.log(node) }
});
Same result.
Am I doing something wrong?
The same kind of problem also happens with "acorn-acorn-object-rest-spread"
Thank you
nehz and orlade