Skip to content

Commit c0ab2a1

Browse files
BridgeARtargos
authored andcommitted
assert: use new language features
This adds new language features to acorn. Otherwise BigInt and other input would not be parsed correct and would not result in nice error messages when using simple assert. PR-URL: #27400 Refs: #27391 Refs: #25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 5f72246 commit c0ab2a1

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lib/assert.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,27 @@ function getCode(fd, line, column) {
203203
function parseCode(code, offset) {
204204
// Lazy load acorn.
205205
if (parseExpressionAt === undefined) {
206-
({ parseExpressionAt } = require('internal/deps/acorn/acorn/dist/acorn'));
206+
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
207+
const privateMethods =
208+
require('internal/deps/acorn-plugins/acorn-private-methods/index');
209+
const bigInt = require('internal/deps/acorn-plugins/acorn-bigint/index');
210+
const classFields =
211+
require('internal/deps/acorn-plugins/acorn-class-fields/index');
212+
const numericSeparator =
213+
require('internal/deps/acorn-plugins/acorn-numeric-separator/index');
214+
const staticClassFeatures =
215+
require('internal/deps/acorn-plugins/acorn-static-class-features/index');
216+
207217
({ findNodeAround } = require('internal/deps/acorn/acorn-walk/dist/walk'));
218+
219+
const Parser = acorn.Parser.extend(
220+
privateMethods,
221+
bigInt,
222+
classFields,
223+
numericSeparator,
224+
staticClassFeatures
225+
);
226+
parseExpressionAt = Parser.parseExpressionAt.bind(Parser);
208227
}
209228
let node;
210229
let start = 0;

0 commit comments

Comments
 (0)