-
-
Notifications
You must be signed in to change notification settings - Fork 148
Closed
Description
To reproduce this:
cd /tmp
mkdir tree-sitter-nodeclass-repro
cd tree-sitter-nodeclass-repro/
npm init -y
npm install tree-sitter tree-sitter-bash tree-sitter-pythonand then create this main.js
const Parser = require('tree-sitter');
const Bash = require('tree-sitter-bash');
const Python = require('tree-sitter-python');
const parser = new Parser();
// parser.setLanguage(Bash);
parser.setLanguage(Python);
const sourceCode = `0`;
const tree = parser.parse(sourceCode);
let i = 0;
try {
for (;; i++) {
for (const n of tree.rootNode.namedChildren) {}
}
} catch (e) {
console.log(i + " iterations");
console.log(e);
process.exit();
}Then run it
while true; do
timeout 1 node main.js
doneIf the error doesn't happen after about a second, it doesn't seem to happen ever (I left node main.js running for 10 minutes). It can take a few tries, but eventually you will see this error
769 iterations
TypeError: NodeClass is not a constructor
at unmarshalNode (/private/tmp/tree-sitter-nodeclass-repro/node_modules/tree-sitter/index.js:783:18)
at Tree.get (/private/tmp/tree-sitter-nodeclass-repro/node_modules/tree-sitter/index.js:25:14)
at Object.<anonymous> (/private/tmp/tree-sitter-nodeclass-repro/main.js:15:26)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Module.load (node:internal/modules/cjs/loader:1205:32)
at Module._load (node:internal/modules/cjs/loader:1021:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12)
at node:internal/main/run_main_module:28:49
It happens when accessing .children as well.
Metadata
Metadata
Assignees
Labels
No labels