Skip to content

Commit

Permalink
assert: use new language features
Browse files Browse the repository at this point in the history
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: nodejs#27400
Refs: nodejs#27391
Refs: nodejs#25835
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
BridgeAR committed Apr 30, 2019
1 parent 72c6ea2 commit 04b7c00
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,27 @@ function getCode(fd, line, column) {
function parseCode(code, offset) {
// Lazy load acorn.
if (parseExpressionAt === undefined) {
({ parseExpressionAt } = require('internal/deps/acorn/acorn/dist/acorn'));
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
const privateMethods =
require('internal/deps/acorn-plugins/acorn-private-methods/index');
const bigInt = require('internal/deps/acorn-plugins/acorn-bigint/index');
const classFields =
require('internal/deps/acorn-plugins/acorn-class-fields/index');
const numericSeparator =
require('internal/deps/acorn-plugins/acorn-numeric-separator/index');
const staticClassFeatures =
require('internal/deps/acorn-plugins/acorn-static-class-features/index');

({ findNodeAround } = require('internal/deps/acorn/acorn-walk/dist/walk'));

const Parser = acorn.Parser.extend(
privateMethods,
bigInt,
classFields,
numericSeparator,
staticClassFeatures
);
parseExpressionAt = Parser.parseExpressionAt.bind(Parser);
}
let node;
let start = 0;
Expand Down

0 comments on commit 04b7c00

Please sign in to comment.