You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get an error of Unexpected private field when using the super keyword in a class function with a private name. It works fine if the method is not private, i.e. no hash (#) in front of the method name. Here's a minimal example with a comparison to acorn.
import { parse } from 'meriyah';
import { parse as aparse } from 'acorn';
const test = `class A extends B
{
#xyz()
{
super.abc();
}
}
`;
console.log( `------------------------ ACORN` );
console.log( aparse( test, { ecmaVersion: 2022 }) );
console.log( `------------------------ MERIYAH` );
console.log( parse( test, { next: true }) );
which produces the following output:
------------------------ ACORN
Node {
type: 'Program',
start: 0,
end: 66,
body: [
Node {
type: 'ClassDeclaration',
start: 0,
end: 65,
id: [Node],
superClass: [Node],
body: [Node]
}
],
sourceType: 'script'
}
------------------------ MERIYAH
file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:181
throw new ParseError(parser.index, parser.line, parser.column, type, ...params);
^
ParseError [SyntaxError]: [5:14]: Unexpected private field
at report (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:181:11)
at parseSuperExpression (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:6090:17)
at parsePrimaryExpression (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:6355:20)
at parseExpressionOrLabelledStatement (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:4935:20)
at parseStatement (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:4920:20)
at parseStatementListItem (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:4870:20)
at parseFunctionBody (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:6061:19)
at parseMethodDefinition (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:6994:18)
at parseClassElementList (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:8407:19)
at parseClassBody (file:///home/.../project/node_modules/meriyah/dist/meriyah.esm.js:8285:19) {
index: 51,
line: 5,
column: 14,
description: '[5:14]: Unexpected private field',
loc: { line: 5, column: 14 }
}
The text was updated successfully, but these errors were encountered:
I get an error of
Unexpected private field
when using thesuper
keyword in a class function with a private name. It works fine if the method is not private, i.e. no hash (#
) in front of the method name. Here's a minimal example with a comparison toacorn
.which produces the following output:
The text was updated successfully, but these errors were encountered: