From 93c78cdf654ea1b2c8a48287f62b7b67c1bda8d9 Mon Sep 17 00:00:00 2001 From: bd82 Date: Mon, 3 Jan 2022 18:17:05 +0200 Subject: [PATCH] fix: cst naming conflicts with built-in Object prototype props fixes #1724 --- packages/chevrotain/benchmark_web/README.md | 2 +- packages/chevrotain/benchmark_web/parsers/options.js | 1 + .../src/parse/parser/traits/recognizer_engine.ts | 2 +- .../chevrotain/src/parse/parser/traits/tree_builder.ts | 8 ++------ packages/website/docs/changes/CHANGELOG.md | 6 ++++++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/chevrotain/benchmark_web/README.md b/packages/chevrotain/benchmark_web/README.md index e024bf1d3..85c13a12f 100644 --- a/packages/chevrotain/benchmark_web/README.md +++ b/packages/chevrotain/benchmark_web/README.md @@ -33,7 +33,7 @@ With the **Next** version (locally built version on current branch). - JS Engines, hotspots optimizations can slightly improve the results on concurrent runs. -8. Inspect the `Relative Speed` column in `index_next.html`, e.g +8. Inspect the `Relative Speed` column in `index_next.html`, e.g: - If it is 105%, there is likely a small performance improvement. - If it is 80% there is a large performance regression. diff --git a/packages/chevrotain/benchmark_web/parsers/options.js b/packages/chevrotain/benchmark_web/parsers/options.js index b10e7a026..a2643e9ad 100644 --- a/packages/chevrotain/benchmark_web/parsers/options.js +++ b/packages/chevrotain/benchmark_web/parsers/options.js @@ -12,6 +12,7 @@ const options = { } }, current: { + // bundle: "../chevrotain.js", bundle: "https://unpkg.com/chevrotain/lib/chevrotain.js", parserConfig: { maxLookahead: 2, diff --git a/packages/chevrotain/src/parse/parser/traits/recognizer_engine.ts b/packages/chevrotain/src/parse/parser/traits/recognizer_engine.ts index 42ac6f971..57401ccfa 100644 --- a/packages/chevrotain/src/parse/parser/traits/recognizer_engine.ts +++ b/packages/chevrotain/src/parse/parser/traits/recognizer_engine.ts @@ -827,7 +827,7 @@ export class RecognizerEngine { this.RULE_OCCURRENCE_STACK.push(idxInCallingRule) this.RULE_STACK.push(shortName) // NOOP when cst is disabled - this.cstInvocationStateUpdate(fullName, shortName) + this.cstInvocationStateUpdate(fullName) } isBackTracking(this: MixedInParser): boolean { diff --git a/packages/chevrotain/src/parse/parser/traits/tree_builder.ts b/packages/chevrotain/src/parse/parser/traits/tree_builder.ts index 300d9f181..f7eeba561 100644 --- a/packages/chevrotain/src/parse/parser/traits/tree_builder.ts +++ b/packages/chevrotain/src/parse/parser/traits/tree_builder.ts @@ -154,14 +154,10 @@ export class TreeBuilder { } } - cstInvocationStateUpdate( - this: MixedInParser, - fullRuleName: string, - shortName: string | number - ): void { + cstInvocationStateUpdate(this: MixedInParser, fullRuleName: string): void { const cstNode: CstNode = { name: fullRuleName, - children: {} + children: Object.create(null) } this.setInitialNodeLocation(cstNode) diff --git a/packages/website/docs/changes/CHANGELOG.md b/packages/website/docs/changes/CHANGELOG.md index c3e1a1569..77c58e29c 100644 --- a/packages/website/docs/changes/CHANGELOG.md +++ b/packages/website/docs/changes/CHANGELOG.md @@ -1,3 +1,9 @@ +## X.Y.Z (INSERT_DATE_HERE) + +#### Bug Fixes + +- [CST naming conflicts with built-in Object prototype props](https://github.com/Chevrotain/chevrotain/issues/1724) + ## 9.1.0 (10-9-2021) #### Minor Changes