Skip to content

Commit 84a0785

Browse files
authored
lang-python: fix unparse roundtrip check in bench.ts (#583)
Fixed the unparse roundtrip check in the Python benchmark. The CST is built from tokenized input (where comments are replaced with spaces), so reconstructing the full source now correctly uses the tokenized input for the prefix before the root node instead of the raw input.
1 parent 58af498 commit 84a0785

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/lang-python/bench.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ bench.add(
6161
const cst = r.getCstRoot();
6262
const {input: tokenizedInput} = tokenize(input);
6363
const root = cst as NonterminalNode;
64-
const fullSource = input.slice(0, root.startIdx) + root.sourceString;
64+
const fullSource = tokenizedInput.slice(0, root.startIdx) + root.sourceString;
6565
if (fullSource !== tokenizedInput) {
6666
console.error('UNPARSE MISMATCH!');
6767
process.exit(1);

0 commit comments

Comments
 (0)