Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
BridgeAR committed Apr 24, 2019
commit 5bfaab376d8a8465dd9d1cd7896d8dae44a992c7
19 changes: 19 additions & 0 deletions 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) {
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
({ parseExpressionAt } = require('internal/deps/acorn/acorn/dist/acorn'));
Comment thread
BridgeAR marked this conversation as resolved.
Outdated
const privateMethods =
require('internal/deps/acorn/acorn-private-methods/index');
const bigInt = require('internal/deps/acorn/acorn-bigint/index');
const classFields = require('internal/deps/acorn/acorn-class-fields/index');
const numericSeparator =
require('internal/deps/acorn/acorn-numeric-separator/index');
const staticClassFeatures =
require('internal/deps/acorn/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