Improve error messages (#980)

swc_ecma_parser:
 - Improve error messages
This commit is contained in:
강동윤 2020-08-21 14:57:16 +09:00 committed by GitHub
parent 3262052e33
commit 993b77b325
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
294 changed files with 700 additions and 442 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "swc_ecma_parser" name = "swc_ecma_parser"
version = "0.34.0" version = "0.34.1"
authors = ["강동윤 <kdy1997.dev@gmail.com>"] authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT" license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git" repository = "https://github.com/swc-project/swc.git"

View File

@ -1,6 +1,5 @@
#![allow(dead_code)] #![allow(dead_code)]
use self::SyntaxError::*;
use crate::token::Token; use crate::token::Token;
use std::{borrow::Cow, fmt::Debug}; use std::{borrow::Cow, fmt::Debug};
use swc_atoms::JsWord; use swc_atoms::JsWord;
@ -31,6 +30,15 @@ impl Error {
#[non_exhaustive] #[non_exhaustive]
pub enum SyntaxError { pub enum SyntaxError {
Eof, Eof,
DeclNotAllowed,
InvalidSuperCall,
InvalidSuper,
ArrowNotAllowed,
ExportNotAllowed,
GetterSetterCannotBeReadonly,
TopLevelAwait, TopLevelAwait,
LegacyDecimal, LegacyDecimal,
@ -79,6 +87,7 @@ pub enum SyntaxError {
/// Unexpected token /// Unexpected token
Unexpected { Unexpected {
got: String, got: String,
expected: &'static str,
}, },
ReservedWordInImport, ReservedWordInImport,
AssignProperty, AssignProperty,
@ -141,6 +150,7 @@ pub enum SyntaxError {
DeclarePrivateIdentifier, DeclarePrivateIdentifier,
ClassProperty, ClassProperty,
ReadOnlyMethod, ReadOnlyMethod,
GeneratorConstructor,
TsBindingPatCannotBeOptional, TsBindingPatCannotBeOptional,
TrailingCommaInsideImport, TrailingCommaInsideImport,
@ -203,20 +213,22 @@ pub enum SyntaxError {
TS2703, TS2703,
} }
impl Error { impl SyntaxError {
#[cold] #[cold]
pub fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder { #[inline(never)]
let span = self.span(); pub fn msg(&self) -> Cow<'static, str> {
match self {
let kind = self.kind(); SyntaxError::TopLevelAwait => "top level await requires target to es2017 or higher \
let msg: Cow<'static, _> = match kind { and topLevelAwait:true for ecmascript"
TopLevelAwait => "top level await requires target to es2017 or higher and \
topLevelAwait:true for ecmascript"
.into(), .into(),
LegacyDecimal => "Legacy decimal escape is not permitted in strict mode".into(), SyntaxError::LegacyDecimal => {
LegacyOctal => "Legacy octal escape is not permitted in strict mode".into(), "Legacy decimal escape is not permitted in strict mode".into()
InvalidIdentChar => "Invalid character in identifier".into(), }
ExpectedDigit { radix } => format!( SyntaxError::LegacyOctal => {
"Legacy octal escape is not permitted in strict mode".into()
}
SyntaxError::InvalidIdentChar => "Invalid character in identifier".into(),
SyntaxError::ExpectedDigit { radix } => format!(
"Expected {} digit", "Expected {} digit",
match radix { match radix {
2 => "a binary", 2 => "a binary",
@ -227,159 +239,304 @@ impl Error {
} }
) )
.into(), .into(),
UnterminatedBlockComment => "Unterminated block comment".into(), SyntaxError::UnterminatedBlockComment => "Unterminated block comment".into(),
UnterminatedStrLit => "Unterminated string constant".into(), SyntaxError::UnterminatedStrLit => "Unterminated string constant".into(),
ExpectedUnicodeEscape => "Expected unicode escape".into(), SyntaxError::ExpectedUnicodeEscape => "Expected unicode escape".into(),
EscapeInReservedWord { ref word } => { SyntaxError::EscapeInReservedWord { ref word } => {
format!("Unexpected escape sequence in reserved word: {}", word).into() format!("Unexpected escape sequence in reserved word: {}", word).into()
} }
UnterminatedRegxp => "Unterminated regexp literal".into(), SyntaxError::UnterminatedRegxp => "Unterminated regexp literal".into(),
UnterminatedTpl => "Unterminated template".into(), SyntaxError::UnterminatedTpl => "Unterminated template".into(),
IdentAfterNum => "Identifier cannot follow number".into(), SyntaxError::IdentAfterNum => "Identifier cannot follow number".into(),
UnexpectedChar { c } => format!("Unexpected character {:?}", c).into(), SyntaxError::UnexpectedChar { c } => format!("Unexpected character {:?}", c).into(),
InvalidStrEscape => "Invalid string escape".into(), SyntaxError::InvalidStrEscape => "Invalid string escape".into(),
InvalidUnicodeEscape => "Invalid unciode escape".into(), SyntaxError::InvalidUnicodeEscape => "Invalid unciode escape".into(),
InvalidCodePoint => "Invalid unciode code point".into(), SyntaxError::InvalidCodePoint => "Invalid unciode code point".into(),
ExpectedHexChars { count } => format!("Expected {} hex characters", count).into(), SyntaxError::ExpectedHexChars { count } => {
LegacyCommentInModule => "Legacy comments cannot be used in module code".into(), format!("Expected {} hex characters", count).into()
NumLitTerminatedWithExp => "Expected +, - or decimal digit after e".into(), }
SyntaxError::LegacyCommentInModule => {
"Legacy comments cannot be used in module code".into()
}
SyntaxError::NumLitTerminatedWithExp => "Expected +, - or decimal digit after e".into(),
InvalidIdentInStrict => "'implements', 'interface', 'let', 'package', 'private', \ SyntaxError::InvalidIdentInStrict => {
'protected', 'public', 'static', or 'yield' cannot be used \ "'implements', 'interface', 'let', 'package', 'private', 'protected', 'public', \
as an identifier in strict mode" 'static', or 'yield' cannot be used as an identifier in strict mode"
.into()
}
SyntaxError::EvalAndArgumentsInStrict => "'eval' and 'arguments' cannot be used as a \
binding identifier in strict mode"
.into(), .into(),
EvalAndArgumentsInStrict => "'eval' and 'arguments' cannot be used as a binding \ SyntaxError::UnaryInExp { .. } => "** cannot be applied to unary expression".into(),
identifier in strict mode" SyntaxError::Hash => "Unexpected token '#'".into(),
.into(), SyntaxError::LineBreakInThrow => "LineBreak cannot follow 'throw'".into(),
UnaryInExp { .. } => "** cannot be applied to unary expression".into(), SyntaxError::LineBreakBeforeArrow => {
Hash => "Unexpected token '#'".into(), "Unexpected line break between arrow head and arrow".into()
LineBreakInThrow => "LineBreak cannot follow 'throw'".into(), }
LineBreakBeforeArrow => "Unexpected line break between arrow head and arrow".into(), SyntaxError::Unexpected {
Unexpected { ref got } => format!("Unexpected token {}", got).into(), ref got,
ref expected,
} => format!("Unexpected token `{}`. Expected {}", got, expected).into(),
ReservedWordInImport => "cannot import as reserved word".into(), SyntaxError::ReservedWordInImport => "cannot import as reserved word".into(),
AssignProperty => "assignment property is invalid syntax".into(), SyntaxError::AssignProperty => "assignment property is invalid syntax".into(),
Expected(token, ref got) => format!("Expected {:?}, got {}", token, got).into(), SyntaxError::Expected(token, ref got) => {
ExpectedSemiForExprStmt { .. } => "Expected ';', '}' or <eof>".into(), format!("Expected {:?}, got {}", token, got).into()
}
SyntaxError::ExpectedSemiForExprStmt { .. } => "Expected ';', '}' or <eof>".into(),
AwaitStar => "await* has been removed from the async functions proposal. Use \ SyntaxError::AwaitStar => "await* has been removed from the async functions proposal. \
Promise.all() instead." Use Promise.all() instead."
.into(), .into(),
ReservedWordInObjShorthandOrPat => { SyntaxError::ReservedWordInObjShorthandOrPat => {
"Cannot use a reserved word as a shorthand property".into() "Cannot use a reserved word as a shorthand property".into()
} }
MultipleDefault { .. } => "A switch block cannot have multiple defaults".into(), SyntaxError::MultipleDefault { .. } => {
CommaAfterRestElement => "Trailing comma isn't permitted after a rest element".into(), "A switch block cannot have multiple defaults".into()
NonLastRestParam => "Rest element must be final element".into(), }
SpreadInParenExpr => "Parenthesized expression cannot contain spread operator".into(), SyntaxError::CommaAfterRestElement => {
EmptyParenExpr => "Parenthized expression cannot be empty".into(), "Trailing comma isn't permitted after a rest element".into()
InvalidPat => "Not a pattern".into(), }
InvalidExpr => "Not an expression".into(), SyntaxError::NonLastRestParam => "Rest element must be final element".into(),
SyntaxError::SpreadInParenExpr => {
"Parenthesized expression cannot contain spread operator".into()
}
SyntaxError::EmptyParenExpr => "Parenthized expression cannot be empty".into(),
SyntaxError::InvalidPat => "Not a pattern".into(),
SyntaxError::InvalidExpr => "Not an expression".into(),
// TODO // TODO
NotSimpleAssign => "Cannot assign to this".into(), SyntaxError::NotSimpleAssign => "Cannot assign to this".into(),
ExpectedIdent => "Expected ident".into(), SyntaxError::ExpectedIdent => "Expected ident".into(),
ExpctedSemi => "Expected ';' or line break".into(), SyntaxError::ExpctedSemi => "Expected ';' or line break".into(),
DuplicateLabel(ref label) => format!("Label {} is already declared", label).into(), SyntaxError::DuplicateLabel(ref label) => {
AsyncGenerator => "An async function cannot be generator".into(), format!("Label {} is already declared", label).into()
NonTopLevelImportExport => "'import', and 'export' are not permitted here".into(), }
ImportExportInScript => { SyntaxError::AsyncGenerator => "An async function cannot be generator".into(),
SyntaxError::NonTopLevelImportExport => {
"'import', and 'export' are not permitted here".into()
}
SyntaxError::ImportExportInScript => {
"'import', and 'export' cannot be used outside of module code".into() "'import', and 'export' cannot be used outside of module code".into()
} }
PatVarWithoutInit => "Destructuring bindings require initializers".into(), SyntaxError::PatVarWithoutInit => "Destructuring bindings require initializers".into(),
WithInStrict => "With statement are not allowed in strict mode".into(), SyntaxError::WithInStrict => "With statement are not allowed in strict mode".into(),
ReturnNotAllowed => "Return statement is not allowed here".into(), SyntaxError::ReturnNotAllowed => "Return statement is not allowed here".into(),
TooManyVarInForInHead => "Expected one variable binding".into(), SyntaxError::TooManyVarInForInHead => "Expected one variable binding".into(),
VarInitializerInForInHead => "Unexpected initializer in for in/of loop".into(), SyntaxError::VarInitializerInForInHead => {
LabelledGenerator => "Generator cannot be labelled".into(), "Unexpected initializer in for in/of loop".into()
YieldParamInGen => "'yield' cannot be used as a parameter within generator".into(), }
AwaitForStmt => "for await syntax is valid only for for-of statement".into(), SyntaxError::LabelledGenerator => "Generator cannot be labelled".into(),
SyntaxError::YieldParamInGen => {
"'yield' cannot be used as a parameter within generator".into()
}
SyntaxError::AwaitForStmt => {
"for await syntax is valid only for for-of statement".into()
}
UnterminatedJSXContents => "Unterminated JSX contents".into(), SyntaxError::UnterminatedJSXContents => "Unterminated JSX contents".into(),
EmptyJSXAttr => "JSX attributes must only be assigned a non-empty expression".into(), SyntaxError::EmptyJSXAttr => {
InvalidJSXValue => { "JSX attributes must only be assigned a non-empty expression".into()
}
SyntaxError::InvalidJSXValue => {
"JSX value should be either an expression or a quoted JSX text".into() "JSX value should be either an expression or a quoted JSX text".into()
} }
JSXExpectedClosingTagForLtGt => "Expected corresponding JSX closing tag for <>".into(), SyntaxError::JSXExpectedClosingTagForLtGt => {
JSXExpectedClosingTag { ref tag } => { "Expected corresponding JSX closing tag for <>".into()
}
SyntaxError::JSXExpectedClosingTag { ref tag } => {
format!("Expected corresponding JSX closing tag for <{}>", tag).into() format!("Expected corresponding JSX closing tag for <{}>", tag).into()
} }
InvalidLeadingDecorator => { SyntaxError::InvalidLeadingDecorator => {
"Leading decorators must be attached to a class declaration".into() "Leading decorators must be attached to a class declaration".into()
} }
DecoratorOnExport => "Using the export keyword between a decorator and a class is not \ SyntaxError::DecoratorOnExport => "Using the export keyword between a decorator and a \
allowed. Please use `export @dec class` instead." class is not allowed. Please use `export @dec \
class` instead."
.into(), .into(),
TsRequiredAfterOptional => { SyntaxError::TsRequiredAfterOptional => {
"A required element cannot follow an optional element.".into() "A required element cannot follow an optional element.".into()
} }
TsInvalidParamPropPat => { SyntaxError::TsInvalidParamPropPat => {
"Typescript parameter property must be identifer or assignment pattern".into() "Typescript parameter property must be identifer or assignment pattern".into()
} }
SpaceBetweenHashAndIdent => "Unexpected space between # and identifier".into(), SyntaxError::SpaceBetweenHashAndIdent => {
AsyncConstructor => "Constructor can't be an async function".into(), "Unexpected space between # and identifier".into()
PropertyNamedConstructor => { }
SyntaxError::AsyncConstructor => "Constructor can't be an async function".into(),
SyntaxError::PropertyNamedConstructor => {
"Classes may not have a non-static field named 'constructor'".into() "Classes may not have a non-static field named 'constructor'".into()
} }
DeclarePrivateIdentifier => { SyntaxError::DeclarePrivateIdentifier => {
"'declare' modifier cannot be used with a private identifier".into() "'declare' modifier cannot be used with a private identifier".into()
} }
ClassProperty => "Class property requires `jsc.parser.classProperty` to be true".into(), SyntaxError::ClassProperty => {
ReadOnlyMethod => "A method cannot be readonly".into(), "Class property requires `jsc.parser.classProperty` to be true".into()
TsBindingPatCannotBeOptional => "A binding pattern parameter cannot be optional in an \ }
implementation signature." SyntaxError::ReadOnlyMethod => "A method cannot be readonly".into(),
SyntaxError::TsBindingPatCannotBeOptional => "A binding pattern parameter cannot be \
optional in an implementation signature."
.into(), .into(),
TrailingCommaInsideImport => { SyntaxError::TrailingCommaInsideImport => {
"Trailing comma is disallowed inside import(...) arguments".into() "Trailing comma is disallowed inside import(...) arguments".into()
} }
DynamicImport => { SyntaxError::DynamicImport => {
"import(...) expressions requires `jsc.parser.dynamicImport` to be true".into() "import(...) expressions requires `jsc.parser.dynamicImport` to be true".into()
} }
ExportDefaultWithOutFrom => "export default statements required from '...';".into(), SyntaxError::ExportDefaultWithOutFrom => {
ExportNamespaceFrom => "export * as Foo from 'foo'; requires \ "export default statements required from '...';".into()
}
SyntaxError::ExportNamespaceFrom => "export * as Foo from 'foo'; requires \
`jsc.parser.exportNamespaceFrom` to be true" `jsc.parser.exportNamespaceFrom` to be true"
.into(), .into(),
DotsWithoutIdentifier => { SyntaxError::DotsWithoutIdentifier => {
"`...` must be followed by an identifier in declaration contexts".into() "`...` must be followed by an identifier in declaration contexts".into()
} }
NumericSeparatorIsAllowedOnlyBetweenTwoDigits => { SyntaxError::NumericSeparatorIsAllowedOnlyBetweenTwoDigits => {
"A numeric separator is only allowed between two digits".into() "A numeric separator is only allowed between two digits".into()
} }
NullishCoalescingWithLogicalOp => "Nullish coalescing operator(??) requires parens \ SyntaxError::NullishCoalescingWithLogicalOp => {
when mixing with logical operators" "Nullish coalescing operator(??) requires parens when mixing with logical operators"
.into(), .into()
NullishCoalescingNotEnabled => { }
SyntaxError::NullishCoalescingNotEnabled => {
"Nullish coalescing operator(??) requires jsc.parser.nullishCoalescing".into() "Nullish coalescing operator(??) requires jsc.parser.nullishCoalescing".into()
} }
TS1056 => "jsc.taraget should be es5 or upper to use getter / setter".into(), SyntaxError::TS1056 => {
TS1110 => "type expected".into(), "jsc.taraget should be es5 or upper to use getter / setter".into()
TS1141 => "literal in an import type should be string literal".into(), }
SyntaxError::TS1110 => "type expected".into(),
SyntaxError::TS1141 => "literal in an import type should be string literal".into(),
Eof => "Unexpected eof".into(), SyntaxError::Eof => "Unexpected eof".into(),
TS2703 => "The operand of a delete operator must be a property reference.".into(), SyntaxError::TS2703 => {
// TODO: "The operand of a delete operator must be a property reference.".into()
_ => format!("{:?}", kind).into(), }
}; SyntaxError::DeclNotAllowed => "Declatation is now allowed".into(),
SyntaxError::InvalidSuperCall => "Invalid `super()`".into(),
SyntaxError::InvalidSuper => "Invalid access to super".into(),
SyntaxError::ArrowNotAllowed => "An arrow function is not allowed here".into(),
SyntaxError::ExportNotAllowed => "`export` is not aloowed here".into(),
SyntaxError::GetterSetterCannotBeReadonly => {
"A getter or a setter cannot be readonly".into()
}
SyntaxError::RestPatInSetter => "Rest pattern is not allowed in setter".into(),
SyntaxError::GeneratorConstructor => "A constructor cannot be generator".into(),
SyntaxError::TS1003 => "Expected an identifier".into(),
SyntaxError::TS1005 => "Expected a semicolon".into(),
SyntaxError::TS1009 => "Trailing comma is not allowed".into(),
SyntaxError::TS1014 => "A rest parameter must be last in a parameter list".into(),
SyntaxError::TS1015 => "Parameter cannot have question mark and initializer".into(),
SyntaxError::TS1031 => "`declare` modifier cannot appear on a class element".into(),
SyntaxError::TS1038 => {
"`declare` modifier not allowed for code already in an ambient context".into()
}
SyntaxError::TS1042 => "`async` modifier cannot be used here".into(),
SyntaxError::TS1047 => "A rest parameter cannot be optional".into(),
SyntaxError::TS1048 => "A rest parameter cannot have an initializer".into(),
SyntaxError::TS1085 => "Legacy octal literals are not available when targeting \
ECMAScript 5 and higher"
.into(),
SyntaxError::TS1089 => {
"'private' modifier cannot appear on a constructor declaration".into()
}
SyntaxError::TS1092 => {
"Type parameters cannot appear on a constructor declaration".into()
}
SyntaxError::TS1096 => "An index signature must have exactly one parameter".into(),
SyntaxError::TS1098 => "Type parameter list cannot be empty".into(),
SyntaxError::TS1100 => "Invalid use of 'arguments' in strict mode".into(),
SyntaxError::TS1102 => {
"'delete' cannot be called on an identifier in strict mode".into()
}
SyntaxError::TS1105 => "A 'break' statement can only be used within an enclosing \
iteration or switch statement"
.into(),
SyntaxError::TS1107 => "Jump target cannot cross function boundary".into(),
SyntaxError::TS1109 => "Expression expected".into(),
SyntaxError::TS1114 => "Duplicate label".into(),
SyntaxError::TS1115 => "A 'continue' statement can only jump to a label of an \
enclosing iteration statement"
.into(),
SyntaxError::TS1116 => {
"A 'break' statement can only jump to a label of an enclosing statement".into()
}
SyntaxError::TS1123 => "Variable declaration list cannot be empty".into(),
SyntaxError::TS1162 => "An object member cannot be declared optional".into(),
SyntaxError::TS1164 => "Computed property names are not allowed in enums".into(),
SyntaxError::TS1171 => {
"A comma expression is not allowed in a computed property name".into()
}
SyntaxError::TS1172 => "`extends` clause already seen.".into(),
SyntaxError::TS1174 => "Classes can only extend a single class".into(),
SyntaxError::TS1175 => "`implements` clause already seen".into(),
SyntaxError::TS1183 => {
"An implementation cannot be declared in ambient contexts".into()
}
SyntaxError::TS1093 => {
"Type annotation cannot appear on a constructor declaration".into()
}
SyntaxError::TS1094 => {
"A `set` accessor must have a corresponding `get` accessor".into()
}
SyntaxError::TS1196 => "Catch clause variable cannot have a type annotation".into(),
SyntaxError::TS1242 => {
"`abstract` modifier can only appear on a class or method declaration".into()
}
SyntaxError::TS2369 => {
"A parameter property is only allowed in a constructor implementation".into()
}
SyntaxError::TS2371 => "A parameter initializer is only allowed in a function or \
constructor implementation"
.into(),
SyntaxError::TS2406 => "Invalid left-hand side in 'for...in' statement".into(),
SyntaxError::TS2410 => "The 'with' statement is not supported. All symbols in a \
'with' block will have type 'any'."
.into(),
SyntaxError::TS2414 => "Invalid class name".into(),
SyntaxError::TS2427 => "interface name is invalid".into(),
SyntaxError::TS2452 => "An enum member cannot have a numeric name".into(),
SyntaxError::TS2483 => {
"The left-hand side of a 'for...of' statement cannot use a type annotation".into()
}
SyntaxError::TS2491 => "The left-hand side of a 'for...in' statement cannot be a \
destructuring pattern"
.into(),
}
}
}
impl Error {
#[cold]
#[inline(never)]
pub fn into_diagnostic(self, handler: &Handler) -> DiagnosticBuilder {
let span = self.span();
let kind = self.kind();
let msg = kind.msg();
let mut db = handler.struct_err(&msg); let mut db = handler.struct_err(&msg);
db.set_span(span); db.set_span(span);
match kind { match kind {
ExpectedSemiForExprStmt { expr } => { SyntaxError::ExpectedSemiForExprStmt { expr } => {
db.span_note( db.span_note(
expr, expr,
"This is the expression part of an expression statement", "This is the expression part of an expression statement",
); );
} }
MultipleDefault { previous } => { SyntaxError::MultipleDefault { previous } => {
db.span_note(previous, "previous default case is declared at here"); db.span_note(previous, "previous default case is declared at here");
} }
_ => {} _ => {}

View File

@ -198,7 +198,7 @@ impl<'a, I: Tokens> Parser<I> {
if is!("export") { if is!("export") {
if !allow_export { if !allow_export {
unexpected!(); syntax_error!(self.input.cur_span(), SyntaxError::ExportNotAllowed);
} }
if !self.syntax().decorators_before_export() { if !self.syntax().decorators_before_export() {
@ -454,11 +454,12 @@ impl<'a, I: Tokens> Parser<I> {
// generator method // generator method
let key = self.parse_class_prop_name()?; let key = self.parse_class_prop_name()?;
if readonly { if readonly {
syntax_error!(span!(start), SyntaxError::ReadOnlyMethod); self.emit_err(span!(start), SyntaxError::ReadOnlyMethod);
} }
if is_constructor(&key) { if is_constructor(&key) {
unexpected!(); self.emit_err(span!(start), SyntaxError::GeneratorConstructor);
} }
return self.make_method( return self.make_method(
|p| p.parse_unique_formal_params(), |p| p.parse_unique_formal_params(),
MakeMethodArgs { MakeMethodArgs {
@ -656,7 +657,7 @@ impl<'a, I: Tokens> Parser<I> {
let key = self.parse_class_prop_name()?; let key = self.parse_class_prop_name()?;
if readonly { if readonly {
unexpected!() self.emit_err(key_span, SyntaxError::GetterSetterCannotBeReadonly);
} }
return match i.sym { return match i.sym {
@ -718,7 +719,7 @@ impl<'a, I: Tokens> Parser<I> {
_ => {} _ => {}
} }
unexpected!() unexpected!("* for generator, private key, identifier or async")
} }
fn make_property( fn make_property(

View File

@ -81,7 +81,7 @@ impl<'a, I: Tokens> Parser<I> {
}) => { }) => {
*type_params = Some(type_parameters); *type_params = Some(type_parameters);
} }
_ => unexpected!(), _ => unexpected!("("),
} }
Ok(Some(arrow)) Ok(Some(arrow))
}); });
@ -374,7 +374,11 @@ impl<'a, I: Tokens> Parser<I> {
} }
} }
unexpected!() unexpected!(
"this, import, async, function, [ for array literal, { for object literal, @ for \
decorator, function, class, null, true, false, number, bigint, string, regexp, ` for \
template literal, (, or an identifier"
)
} }
fn parse_array_lit(&mut self) -> PResult<Box<Expr>> { fn parse_array_lit(&mut self) -> PResult<Box<Expr>> {
@ -422,7 +426,7 @@ impl<'a, I: Tokens> Parser<I> {
let prop = if is!("meta") { let prop = if is!("meta") {
self.parse_ident_name()? self.parse_ident_name()?
} else { } else {
unexpected!(); unexpected!("meta");
}; };
Ok(MetaPropExpr { meta, prop }) Ok(MetaPropExpr { meta, prop })
@ -446,7 +450,7 @@ impl<'a, I: Tokens> Parser<I> {
return self.parse_subscripts(ExprOrSuper::Expr(expr), true); return self.parse_subscripts(ExprOrSuper::Expr(expr), true);
} }
unexpected!() unexpected!("target")
} }
// 'NewExpression' allows new call without paren. // 'NewExpression' allows new call without paren.
@ -457,7 +461,8 @@ impl<'a, I: Tokens> Parser<I> {
self.try_parse_ts(|p| { self.try_parse_ts(|p| {
let args = p.parse_ts_type_args()?; let args = p.parse_ts_type_args()?;
if !is!('(') { if !is!('(') {
unexpected!() // This will fail
expect!('(');
} }
Ok(Some(args)) Ok(Some(args))
}) })
@ -626,7 +631,7 @@ impl<'a, I: Tokens> Parser<I> {
syntax_error!(span!(expr_start), SyntaxError::LineBreakBeforeArrow); syntax_error!(span!(expr_start), SyntaxError::LineBreakBeforeArrow);
} }
if !can_be_arrow { if !can_be_arrow {
unexpected!() syntax_error!(span!(expr_start), SyntaxError::ArrowNotAllowed);
} }
expect!("=>"); expect!("=>");
@ -834,7 +839,7 @@ impl<'a, I: Tokens> Parser<I> {
), ),
_ => unreachable!(), _ => unreachable!(),
}, },
_ => unexpected!(), _ => unexpected!("template token"),
}; };
let tail = is!('`'); let tail = is!('`');
Ok(TplElement { Ok(TplElement {
@ -934,7 +939,11 @@ impl<'a, I: Tokens> Parser<I> {
.map(|expr| (Box::new(Expr::TaggedTpl(expr)), true)) .map(|expr| (Box::new(Expr::TaggedTpl(expr)), true))
.map(Some) .map(Some)
} else { } else {
unexpected!() if no_call {
unexpected!("`")
} else {
unexpected!("( or `")
}
} }
}); });
if let Some(result) = result { if let Some(result) = result {
@ -1037,9 +1046,9 @@ impl<'a, I: Tokens> Parser<I> {
} }
ExprOrSuper::Super(..) => { ExprOrSuper::Super(..) => {
if no_call { if no_call {
unexpected!() syntax_error!(self.input.cur_span(), SyntaxError::InvalidSuperCall);
} }
unexpected!() syntax_error!(self.input.cur_span(), SyntaxError::InvalidSuper);
} }
} }
} }

View File

@ -21,7 +21,7 @@ impl<'a, I: Tokens> Parser<I> {
_ => unreachable!(), _ => unreachable!(),
}, },
_ if ctx.in_forced_jsx_context => self.parse_ident_ref(), _ if ctx.in_forced_jsx_context => self.parse_ident_ref(),
_ => unexpected!(), _ => unexpected!("jsx identifier"),
} }
} }
@ -216,7 +216,7 @@ impl<'a, I: Tokens> Parser<I> {
} }
let self_closing = eat!('/'); let self_closing = eat!('/');
if !eat!(JSXTagEnd) & !(self.ctx().in_forced_jsx_context && eat!('>')) { if !eat!(JSXTagEnd) & !(self.ctx().in_forced_jsx_context && eat!('>')) {
unexpected!() unexpected!("> (jsx closing tag)");
} }
Ok(JSXOpeningElement { Ok(JSXOpeningElement {
span: span!(start), span: span!(start),
@ -314,7 +314,7 @@ impl<'a, I: Tokens> Parser<I> {
); );
} }
} }
_ => unexpected!(), _ => unexpected!("< (jsx tag start), jsx text or {"),
} }
} }
} }

View File

@ -1,7 +1,17 @@
macro_rules! unexpected { macro_rules! unexpected {
($p:expr) => {{ ($p:expr, $expected:literal) => {{
let got = format!("{:?}", cur!($p, false).ok()); let got = match cur!($p, false).ok() {
syntax_error!($p, $p.input.cur_span(), SyntaxError::Unexpected { got }) Some(v) => format!("{:?}", v),
None => format!("<eof>"),
};
syntax_error!(
$p,
$p.input.cur_span(),
SyntaxError::Unexpected {
got,
expected: $expected
}
)
}}; }};
} }

View File

@ -153,6 +153,8 @@ impl<I: Tokens> Parser<I> {
self.input.get_ctx() self.input.get_ctx()
} }
#[cold]
#[inline(never)]
fn emit_err(&self, span: Span, error: SyntaxError) { fn emit_err(&self, span: Span, error: SyntaxError) {
if !self.emit_err || !self.syntax().early_errors() { if !self.emit_err || !self.syntax().early_errors() {
return; return;
@ -163,6 +165,8 @@ impl<I: Tokens> Parser<I> {
}) })
} }
#[cold]
#[inline(never)]
fn emit_error(&self, error: Error) { fn emit_error(&self, error: Error) {
if !self.emit_err || !self.syntax().early_errors() { if !self.emit_err || !self.syntax().early_errors() {
return; return;

View File

@ -97,7 +97,9 @@ impl<'a, I: Tokens> Parser<I> {
expr, expr,
}) })
} }
_ => unexpected!(), _ => unexpected!(
"identifier, string literal, numeric literal or [ for the computed key"
),
}; };
Ok(v) Ok(v)
@ -198,7 +200,8 @@ impl<I: Tokens> ParseObject<Box<Expr>> for Parser<I> {
let ident = match key { let ident = match key {
PropName::Ident(ident) => ident, PropName::Ident(ident) => ident,
_ => unexpected!(), // TODO
_ => unexpected!("identifier"),
}; };
if eat!('?') { if eat!('?') {
@ -347,7 +350,16 @@ impl<I: Tokens> ParseObject<Box<Expr>> for Parser<I> {
_ => unreachable!(), _ => unreachable!(),
} }
} }
_ => unexpected!(), _ => {
if self.input.syntax().typescript() {
unexpected!(
"... , *, (, [, :, , ?, =, an identifier, public, protected, private, \
readonly, <."
)
} else {
unexpected!("... , *, (, [, :, , ?, = or an identifier")
}
}
} }
} }
} }
@ -412,7 +424,7 @@ impl<I: Tokens> ParseObject<Pat> for Parser<I> {
} }
let key = match key { let key = match key {
PropName::Ident(ident) => ident, PropName::Ident(ident) => ident,
_ => unexpected!(), _ => unexpected!("an identifier"),
}; };
let value = if eat!('=') { let value = if eat!('=') {

View File

@ -51,7 +51,7 @@ impl<'a, I: Tokens> Parser<I> {
// expect!(')'); // expect!(')');
// Ok(pat) // Ok(pat)
// } // }
_ => unexpected!(), _ => unexpected!("yield, an identifier, [ or {"),
} }
} }

View File

@ -172,7 +172,7 @@ impl<'a, I: Tokens> Parser<I> {
if is!("function") { if is!("function") {
if !include_decl { if !include_decl {
unexpected!() self.emit_err(self.input.cur_span(), SyntaxError::DeclNotAllowed);
} }
return self.parse_fn_decl(decorators).map(Stmt::from); return self.parse_fn_decl(decorators).map(Stmt::from);
@ -180,7 +180,7 @@ impl<'a, I: Tokens> Parser<I> {
if is!("class") { if is!("class") {
if !include_decl { if !include_decl {
unexpected!() self.emit_err(self.input.cur_span(), SyntaxError::DeclNotAllowed);
} }
return self return self
.parse_class_decl(start, start, decorators) .parse_class_decl(start, start, decorators)

View File

@ -148,7 +148,7 @@ impl<'a, I: Tokens> Parser<I> {
imported: None, imported: None,
})) }))
} }
_ => unexpected!(), _ => unexpected!("an identifier"),
} }
} }
@ -503,7 +503,7 @@ impl<'a, I: Tokens> Parser<I> {
}, },
_ => unreachable!(), _ => unreachable!(),
}, },
_ => unexpected!(), _ => unexpected!("a string literal"),
}; };
expect!(';'); expect!(';');
Ok(src) Ok(src)

View File

@ -376,7 +376,7 @@ impl<I: Tokens> Parser<I> {
let start = cur_pos!(); let start = cur_pos!();
if !is!('<') && !is!(JSXTagStart) { if !is!('<') && !is!(JSXTagStart) {
unexpected!() unexpected!("< (jsx tag start)")
} }
bump!(); // '<' bump!(); // '<'
@ -534,12 +534,23 @@ impl<I: Tokens> Parser<I> {
} }
/// `tsExpectThenParseType` /// `tsExpectThenParseType`
fn expect_then_parse_ts_type(&mut self, token: &'static Token) -> PResult<Box<TsType>> { fn expect_then_parse_ts_type(
&mut self,
token: &'static Token,
token_str: &'static str,
) -> PResult<Box<TsType>> {
debug_assert!(self.input.syntax().typescript()); debug_assert!(self.input.syntax().typescript());
self.in_type().parse_with(|p| { self.in_type().parse_with(|p| {
if !p.input.eat(token) { if !p.input.eat(token) {
unexpected!() let got = format!("{:?}", cur!(false).ok());
syntax_error!(
p.input.cur_span(),
SyntaxError::Unexpected {
got,
expected: token_str
}
);
} }
p.parse_ts_type() p.parse_ts_type()
@ -711,7 +722,7 @@ impl<I: Tokens> Parser<I> {
})?; })?;
(false, id) (false, id)
} else { } else {
unexpected!(); unexpected!("global or a string literal");
}; };
let body = if is!('{') { let body = if is!('{') {
@ -919,7 +930,7 @@ impl<I: Tokens> Parser<I> {
let id = self.parse_ident_name()?; let id = self.parse_ident_name()?;
let type_params = self.try_parse_ts_type_params()?; let type_params = self.try_parse_ts_type_params()?;
let type_ann = self.expect_then_parse_ts_type(&tok!('='))?; let type_ann = self.expect_then_parse_ts_type(&tok!('='), "=")?;
expect!(';'); expect!(';');
Ok(TsTypeAliasDecl { Ok(TsTypeAliasDecl {
declare: false, declare: false,
@ -981,7 +992,7 @@ impl<I: Tokens> Parser<I> {
expect!('('); expect!('(');
match *cur!(true)? { match *cur!(true)? {
Token::Str { .. } => {} Token::Str { .. } => {}
_ => unexpected!(), _ => unexpected!("a string literal"),
} }
let expr = match self.parse_lit()? { let expr = match self.parse_lit()? {
Lit::Str(s) => s, Lit::Str(s) => s,
@ -1362,7 +1373,7 @@ impl<I: Tokens> Parser<I> {
let start = cur_pos!(); let start = cur_pos!();
let name = self.parse_ident_name()?; let name = self.parse_ident_name()?;
let constraint = Some(self.expect_then_parse_ts_type(&tok!("in"))?); let constraint = Some(self.expect_then_parse_ts_type(&tok!("in"), "in")?);
Ok(TsTypeParam { Ok(TsTypeParam {
span: span!(start), span: span!(start),
@ -1601,7 +1612,10 @@ impl<I: Tokens> Parser<I> {
Pat::Array(pat) => TsFnParam::Array(pat), Pat::Array(pat) => TsFnParam::Array(pat),
Pat::Object(pat) => TsFnParam::Object(pat), Pat::Object(pat) => TsFnParam::Object(pat),
Pat::Rest(pat) => TsFnParam::Rest(pat), Pat::Rest(pat) => TsFnParam::Rest(pat),
_ => unexpected!(), _ => unexpected!(
"an identifier, [ for an array pattern, { for an object patter or ... for a \
rest pattern"
),
}; };
list.push(item); list.push(item);
} }
@ -1723,7 +1737,7 @@ impl<I: Tokens> Parser<I> {
Token::Num(..) => false, Token::Num(..) => false,
_ => true, _ => true,
} { } {
unexpected!() unexpected!("a numeric literal")
} }
let lit = self.parse_lit()?; let lit = self.parse_lit()?;
let lit = match lit { let lit = match lit {
@ -1781,7 +1795,10 @@ impl<I: Tokens> Parser<I> {
// switch (self.state.type) { // switch (self.state.type) {
// } // }
unexpected!() unexpected!(
"an identifier, void, yield, null, await, break, a string literal, a numeric literal, \
true, false, `, -, import, this, typeof, {, [, ("
)
} }
/// `tsParseArrayTypeOrHigher` /// `tsParseArrayTypeOrHigher`

View File

@ -14,7 +14,7 @@ use swc_common::Span;
pub(crate) use swc_ecma_ast::AssignOp as AssignOpToken; pub(crate) use swc_ecma_ast::AssignOp as AssignOpToken;
use swc_ecma_ast::BinaryOp; use swc_ecma_ast::BinaryOp;
#[derive(Kind, Debug, Clone, PartialEq)] #[derive(Kind, Clone, PartialEq)]
#[kind(functions(starts_expr = "bool", before_expr = "bool"))] #[kind(functions(starts_expr = "bool", before_expr = "bool"))]
pub enum Token { pub enum Token {
/// Identifier, "null", "true", "false". /// Identifier, "null", "true", "false".
@ -568,3 +568,51 @@ impl Word {
} }
} }
} }
impl Debug for Token {
/// This method is called only in the case of parsing failure.
#[cold]
#[inline(never)]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Token::Word(w) => write!(f, "{:?}", w)?,
Arrow => write!(f, "=>")?,
Hash => write!(f, "#")?,
At => write!(f, "@")?,
Dot => write!(f, ".")?,
DotDotDot => write!(f, "...")?,
Bang => write!(f, "!")?,
LParen => write!(f, "(")?,
RParen => write!(f, ")")?,
LBracket => write!(f, "[")?,
RBracket => write!(f, "]")?,
LBrace => write!(f, "{{")?,
RBrace => write!(f, "}}")?,
Semi => write!(f, ";")?,
Comma => write!(f, ",")?,
BackQuote => write!(f, "`")?,
Template { raw, .. } => write!(f, "template token ({})", raw)?,
Colon => write!(f, ":")?,
ColonColon => write!(f, "::")?,
BinOp(op) => write!(f, "{}", BinaryOp::from(*op).as_str())?,
AssignOp(op) => write!(f, "{}", op.as_str())?,
DollarLBrace => write!(f, "${{")?,
QuestionMark => write!(f, "?")?,
PlusPlus => write!(f, "++")?,
MinusMinus => write!(f, "--")?,
Tilde => write!(f, "~")?,
Str { value, .. } => write!(f, "string literal ({})", value)?,
Regex(exp, flags) => write!(f, "regexp literal ({}, {})", exp, flags)?,
Num(..) => write!(f, "numeric literal")?,
BigInt(..) => write!(f, "bigint literal")?,
JSXName { name } => write!(f, "jsx name ({})", name)?,
JSXText { raw } => write!(f, "jsx text ({})", raw)?,
JSXTagStart => write!(f, "< (jsx tag start)")?,
JSXTagEnd => write!(f, "> (jsx tag end)")?,
Shebang(_) => write!(f, "#!")?,
Token::Error(_) => write!(f, "<lexing error>")?,
}
Ok(())
}
}

View File

@ -1,10 +1,10 @@
error: Unexpected token Some(JSXTagEnd) error: Unexpected token `> (jsx tag end)`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/jsx/errors/attribute-empty-expression/input.js:1:14 --> $DIR/tests/jsx/errors/attribute-empty-expression/input.js:1:14
| |
1 | <foo bar={} /> 1 | <foo bar={} />
| ^ | ^
error: TS1109 error: Expression expected
--> $DIR/tests/jsx/errors/attribute-empty-expression/input.js:1:13 --> $DIR/tests/jsx/errors/attribute-empty-expression/input.js:1:13
| |
1 | <foo bar={} /> 1 | <foo bar={} />

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(AssignOp("=")) error: Unexpected token `=`. Expected jsx identifier
--> $DIR/tests/jsx/errors/attributes-in-fragment/input.js:1:6 --> $DIR/tests/jsx/errors/attributes-in-fragment/input.js:1:6
| |
1 | < key="nope"></> 1 | < key="nope"></>

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Word(你)) error: Unexpected token `你`. Expected jsx identifier
--> $DIR/tests/jsx/errors/unicode-escape-in-identifier/input.js:1:2 --> $DIR/tests/jsx/errors/unicode-escape-in-identifier/input.js:1:2
| |
1 | <\u{2F804}></\u{2F804}> 1 | <\u{2F804}></\u{2F804}>

View File

@ -1,4 +1,4 @@
error: TS1009 error: Trailing comma is not allowed
--> $DIR/tests/test262-parser/fail/0053737b6145994c.js:1:6 --> $DIR/tests/test262-parser/fail/0053737b6145994c.js:1:6
| |
1 | var x, ; 1 | var x, ;

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(LBrace) error: Unexpected token `{`. Expected identifier, string literal, numeric literal or [ for the computed key
--> $DIR/tests/test262-parser/fail/0131cd88c5774915.js:1:6 --> $DIR/tests/test262-parser/fail/0131cd88c5774915.js:1:6
| |
1 | ({get{a}:0}) 1 | ({get{a}:0})

View File

@ -1,4 +1,4 @@
error: TS1048 error: A rest parameter cannot have an initializer
--> $DIR/tests/test262-parser/fail/043ab1c3982db3cd.js:1:15 --> $DIR/tests/test262-parser/fail/043ab1c3982db3cd.js:1:15
| |
1 | function x(...a = 1){} 1 | function x(...a = 1){}

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Comma) error: Unexpected token `,`. Expected an identifier
--> $DIR/tests/test262-parser/fail/0557c70da3f698b5.module.js:1:11 --> $DIR/tests/test262-parser/fail/0557c70da3f698b5.module.js:1:11
| |
1 | import {b,,c} from 'a'; 1 | import {b,,c} from 'a';

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Word(prop)) error: Unexpected token `prop`. Expected target
--> $DIR/tests/test262-parser/fail/0817f13d2237d8d2.js:1:5 --> $DIR/tests/test262-parser/fail/0817f13d2237d8d2.js:1:5
| |
1 | new.prop 1 | new.prop

View File

@ -1,4 +1,4 @@
error: Expected Comma, got Some(LBrace) error: Expected ,, got Some({)
--> $DIR/tests/test262-parser/fail/08fa65d2ecddcfbe.js:1:13 --> $DIR/tests/test262-parser/fail/08fa65d2ecddcfbe.js:1:13
| |
1 | ({ set: s() { } }) 1 | ({ set: s() { } })

View File

@ -1,4 +1,4 @@
error: Expected Semi, got Some(Num(42.0)) error: Expected ;, got Some(numeric literal)
--> $DIR/tests/test262-parser/fail/0a225effb5493c00.js:1:15 --> $DIR/tests/test262-parser/fail/0a225effb5493c00.js:1:15
| |
1 | for (const of 42); 1 | for (const of 42);

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Semi) error: Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/0abefbc80bf651fa.js:1:15 --> $DIR/tests/test262-parser/fail/0abefbc80bf651fa.js:1:15
| |
1 | for (let let;;;) {} 1 | for (let let;;;) {}

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Comma) error: Unexpected token `,`. Expected identifier, string literal, numeric literal or [ for the computed key
--> $DIR/tests/test262-parser/fail/0d4ff79ab93c897a.js:1:5 --> $DIR/tests/test262-parser/fail/0d4ff79ab93c897a.js:1:5
| |
1 | ({a,,} = 0) 1 | ({a,,} = 0)

View File

@ -1,4 +1,4 @@
error: TS1009 error: Trailing comma is not allowed
--> $DIR/tests/test262-parser/fail/0dbe57298be12eac.js:1:6 --> $DIR/tests/test262-parser/fail/0dbe57298be12eac.js:1:6
| |
1 | var x,; 1 | var x,;

View File

@ -1,4 +1,4 @@
error: Expected Semi, got Some(RParen) error: Expected ;, got Some())
--> $DIR/tests/test262-parser/fail/0ddab4a1a651034c.js:1:24 --> $DIR/tests/test262-parser/fail/0ddab4a1a651034c.js:1:24
| |
1 | for (let x = 42 in list) process(x); 1 | for (let x = 42 in list) process(x);

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/0eb4ed330b5d7e2f.js:1:1 --> $DIR/tests/test262-parser/fail/0eb4ed330b5d7e2f.js:1:1
| |
1 | ({get a(){}})=0 1 | ({get a(){}})=0

View File

@ -1,4 +1,4 @@
error: TS1009 error: Trailing comma is not allowed
--> $DIR/tests/test262-parser/fail/11db90549ed49ac3.js:1:6 --> $DIR/tests/test262-parser/fail/11db90549ed49ac3.js:1:6
| |
1 | let x,; 1 | let x,;

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/12a3250154ea8ef5.js:1:5 --> $DIR/tests/test262-parser/fail/12a3250154ea8ef5.js:1:5
| |
1 | for(let ? b : c in 0); 1 | for(let ? b : c in 0);

View File

@ -1,4 +1,4 @@
error: TS1109 error: Expression expected
--> $DIR/tests/test262-parser/fail/12f5bc355427b8f8.js:1:4 --> $DIR/tests/test262-parser/fail/12f5bc355427b8f8.js:1:4
| |
1 | () + 0 1 | () + 0

View File

@ -1,4 +1,4 @@
error: Expected Comma, got Some(Dot) error: Expected ,, got Some(.)
--> $DIR/tests/test262-parser/fail/143481afd6573e9b.js:1:18 --> $DIR/tests/test262-parser/fail/143481afd6573e9b.js:1:18
| |
1 | function* a({e: a.b}) {} 1 | function* a({e: a.b}) {}

View File

@ -1,4 +1,4 @@
error: Expected Semi, got Some(RParen) error: Expected ;, got Some())
--> $DIR/tests/test262-parser/fail/154f02d86fce5e81.js:1:22 --> $DIR/tests/test262-parser/fail/154f02d86fce5e81.js:1:22
| |
1 | for (const x = 0 in y){} 1 | for (const x = 0 in y){}

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/15de970e269ae56f.js:1:1 --> $DIR/tests/test262-parser/fail/15de970e269ae56f.js:1:1
| |
1 | (1 + 1) = 10 1 | (1 + 1) = 10

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/168502012959421f.js:1:5 --> $DIR/tests/test262-parser/fail/168502012959421f.js:1:5
| |
1 | for(([a]) of 0); 1 | for(([a]) of 0);

View File

@ -1,4 +1,4 @@
error: Expected LParen, got Some(Word(yield)) error: Expected (, got Some(yield)
--> $DIR/tests/test262-parser/fail/16947dc1d11e5e70.js:1:11 --> $DIR/tests/test262-parser/fail/16947dc1d11e5e70.js:1:11
| |
1 | (function*yield(){}) 1 | (function*yield(){})

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Dot) error: Unexpected token `.`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/17904d9a6b6ec31b.js:1:3 --> $DIR/tests/test262-parser/fail/17904d9a6b6ec31b.js:1:3
| |
1 | f(..a) 1 | f(..a)

View File

@ -1,4 +1,4 @@
error: Expected LBrace, got Some(BinOp(Add)) error: Expected {, got Some(+)
--> $DIR/tests/test262-parser/fail/1976350e287d5156.js:1:19 --> $DIR/tests/test262-parser/fail/1976350e287d5156.js:1:19
| |
1 | class A extends a + b {} 1 | class A extends a + b {}

View File

@ -1,4 +1,4 @@
error: Expected RBrace, got Some(Semi) error: Expected }, got Some(;)
--> $DIR/tests/test262-parser/fail/1acada3c651821cf.js:1:12 --> $DIR/tests/test262-parser/fail/1acada3c651821cf.js:1:12
| |
1 | `hello ${10;test` 1 | `hello ${10;test`

View File

@ -1,4 +1,4 @@
error: Unexpected token None error: Unexpected token `<eof>`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/1aefe47e20eb91fa.module.js:1:1 --> $DIR/tests/test262-parser/fail/1aefe47e20eb91fa.module.js:1:1
| |
1 | await 1 | await

View File

@ -1,4 +1,4 @@
error: Expected LBrace, got Some(Num(3.0)) error: Expected {, got Some(numeric literal)
--> $DIR/tests/test262-parser/fail/1b0b9bca042d4440.module.js:1:8 --> $DIR/tests/test262-parser/fail/1b0b9bca042d4440.module.js:1:8
| |
1 | export 3 1 | export 3

View File

@ -1,4 +1,4 @@
error: Expected Comma, got Some(Dot) error: Expected ,, got Some(.)
--> $DIR/tests/test262-parser/fail/1b2e164ac5015a12.js:1:10 --> $DIR/tests/test262-parser/fail/1b2e164ac5015a12.js:1:10
| |
1 | ({a({e: a.b}){}}) 1 | ({a({e: a.b}){}})

View File

@ -1,4 +1,4 @@
error: Expected Word(from), got Some(Semi) error: Expected from, got Some(;)
--> $DIR/tests/test262-parser/fail/1bc43dd97a16b9bb.module.js:1:10 --> $DIR/tests/test262-parser/fail/1bc43dd97a16b9bb.module.js:1:10
| |
1 | import {}; 1 | import {};

View File

@ -1,4 +1,4 @@
error: Expected RBracket, got Some(Word(iter)) error: Expected ], got Some(iter)
--> $DIR/tests/test262-parser/fail/1bde73ba53c309c8.js:1:12 --> $DIR/tests/test262-parser/fail/1bde73ba53c309c8.js:1:12
| |
1 | ({ *[yield iter]() {} }) 1 | ({ *[yield iter]() {} })

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Arrow) error: Unexpected token `=>`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/211656c4eaff2d9c.js:2:1 --> $DIR/tests/test262-parser/fail/211656c4eaff2d9c.js:2:1
| |
2 | => 0 2 | => 0

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/23368c25ea374e2f.js:1:1 --> $DIR/tests/test262-parser/fail/23368c25ea374e2f.js:1:1
| |
1 | (a,b)=(c,d); 1 | (a,b)=(c,d);

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Dot) error: Unexpected token `.`. Expected yield, an identifier, [ or {
--> $DIR/tests/test262-parser/fail/235adc0d4af204c6.js:1:7 --> $DIR/tests/test262-parser/fail/235adc0d4af204c6.js:1:7
| |
1 | var [a.b] = 0 1 | var [a.b] = 0

View File

@ -1,4 +1,4 @@
error: Expected RBracket, got None error: Expected ], got None
--> $DIR/tests/test262-parser/fail/245843abef9e72e7.js:1:1 --> $DIR/tests/test262-parser/fail/245843abef9e72e7.js:1:1
| |
1 | [ 1 | [

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Word(yield)) error: Unexpected token `yield`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/247e71c8786de6b6.js:1:31 --> $DIR/tests/test262-parser/fail/247e71c8786de6b6.js:1:31
| |
1 | (function() { "use strict"; f(yield v) }) 1 | (function() { "use strict"; f(yield v) })

View File

@ -1,4 +1,4 @@
error: Expected RParen, got Some(LParen) error: Expected ), got Some(()
--> $DIR/tests/test262-parser/fail/25b1013a4046bd70.js:1:21 --> $DIR/tests/test262-parser/fail/25b1013a4046bd70.js:1:21
| |
1 | try {} catch (answer()) {} 1 | try {} catch (answer()) {}

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Word(a)) error: Unexpected token `a`. Expected a string literal
--> $DIR/tests/test262-parser/fail/26c0710a6449872a.module.js:1:20 --> $DIR/tests/test262-parser/fail/26c0710a6449872a.module.js:1:20
| |
1 | export {as b} from a 1 | export {as b} from a

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/2884c585d2f035a5.js:1:2 --> $DIR/tests/test262-parser/fail/2884c585d2f035a5.js:1:2
| |
1 | (([a])=0); 1 | (([a])=0);

View File

@ -1,4 +1,4 @@
error: TS1009 error: Trailing comma is not allowed
--> $DIR/tests/test262-parser/fail/2cbdd5fad4e5332d.js:2:4 --> $DIR/tests/test262-parser/fail/2cbdd5fad4e5332d.js:2:4
| |
2 | y,; 2 | y,;

View File

@ -1,10 +1,10 @@
error: Expected LBrace, got None error: Expected {, got None
--> $DIR/tests/test262-parser/fail/2d1410e37ecc3647.js:1:23 --> $DIR/tests/test262-parser/fail/2d1410e37ecc3647.js:1:23
| |
1 | function f(a, ...b = 0) 1 | function f(a, ...b = 0)
| ^ | ^
error: TS1048 error: A rest parameter cannot have an initializer
--> $DIR/tests/test262-parser/fail/2d1410e37ecc3647.js:1:18 --> $DIR/tests/test262-parser/fail/2d1410e37ecc3647.js:1:18
| |
1 | function f(a, ...b = 0) 1 | function f(a, ...b = 0)

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Word(a)) error: Unexpected token `a`. Expected a string literal
--> $DIR/tests/test262-parser/fail/2d86a01ca9731879.module.js:1:19 --> $DIR/tests/test262-parser/fail/2d86a01ca9731879.module.js:1:19
| |
1 | export {a,b} from a 1 | export {a,b} from a

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/2e8378f658290622.js:1:6 --> $DIR/tests/test262-parser/fail/2e8378f658290622.js:1:6
| |
1 | for (+i in {}); 1 | for (+i in {});

View File

@ -1,4 +1,4 @@
error: RestPatInSetter error: Rest pattern is not allowed in setter
--> $DIR/tests/test262-parser/fail/2f95824f19005b11.js:1:19 --> $DIR/tests/test262-parser/fail/2f95824f19005b11.js:1:19
| |
1 | var a = { set foo(...v) {} }; 1 | var a = { set foo(...v) {} };

View File

@ -1,4 +1,4 @@
error: TS1009 error: Trailing comma is not allowed
--> $DIR/tests/test262-parser/fail/305ebbf168c6d218.js:1:6 --> $DIR/tests/test262-parser/fail/305ebbf168c6d218.js:1:6
| |
1 | let x, 1 | let x,

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(RBracket) error: Unexpected token `]`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/3118eaa619345896.js:2:3 --> $DIR/tests/test262-parser/fail/3118eaa619345896.js:2:3
| |
2 | */] 2 | */]

View File

@ -1,4 +1,4 @@
error: Expected Semi, got Some(RParen) error: Expected ;, got Some())
--> $DIR/tests/test262-parser/fail/3162394f5bc07198.js:1:21 --> $DIR/tests/test262-parser/fail/3162394f5bc07198.js:1:21
| |
1 | for(const a = 0 in b); 1 | for(const a = 0 in b);

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Dot) error: Unexpected token `.`. Expected target
--> $DIR/tests/test262-parser/fail/324ab48c6d89125d.js:1:20 --> $DIR/tests/test262-parser/fail/324ab48c6d89125d.js:1:20
| |
1 | function f() { new..target; } 1 | function f() { new..target; }

View File

@ -1,4 +1,4 @@
error: TS1014 error: A rest parameter must be last in a parameter list
--> $DIR/tests/test262-parser/fail/338848861369f3b7.js:1:11 --> $DIR/tests/test262-parser/fail/338848861369f3b7.js:1:11
| |
1 | (function(...a, b){}) 1 | (function(...a, b){})

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Colon) error: Unexpected token `:`. Expected * for generator, private key, identifier or async
--> $DIR/tests/test262-parser/fail/33bc068464342558.js:1:10 --> $DIR/tests/test262-parser/fail/33bc068464342558.js:1:10
| |
1 | (class {a:0}) 1 | (class {a:0})

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(RParen) error: Unexpected token `)`. Expected yield, an identifier, [ or {
--> $DIR/tests/test262-parser/fail/33cf50480671cfec.js:1:15 --> $DIR/tests/test262-parser/fail/33cf50480671cfec.js:1:15
| |
1 | try { } catch() {} 1 | try { } catch() {}

View File

@ -1,4 +1,4 @@
error: Expected Semi, got Some(RParen) error: Expected ;, got Some())
--> $DIR/tests/test262-parser/fail/33d43e9f01bda5ce.js:1:20 --> $DIR/tests/test262-parser/fail/33d43e9f01bda5ce.js:1:20
| |
1 | for (let x = 0 in y){} 1 | for (let x = 0 in y){}

View File

@ -1,4 +1,4 @@
error: Expected Comma, got Some(Num(3.0)) error: Expected ,, got Some(numeric literal)
--> $DIR/tests/test262-parser/fail/3425ca087ec1adb1.js:1:19 --> $DIR/tests/test262-parser/fail/3425ca087ec1adb1.js:1:19
| |
1 | var {x: y = yield 3} = z; 1 | var {x: y = yield 3} = z;

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(RParen) error: Invalid access to super
--> $DIR/tests/test262-parser/fail/3558f8c0f0ba825b.js:1:43 --> $DIR/tests/test262-parser/fail/3558f8c0f0ba825b.js:1:43
| |
1 | class A extends B { constructor() { (super).a(); } } 1 | class A extends B { constructor() { (super).a(); } }

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(DotDotDot) error: Unexpected token `...`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/363ecb9e2e556694.js:1:11 --> $DIR/tests/test262-parser/fail/363ecb9e2e556694.js:1:11
| |
1 | new f(... ... g); 1 | new f(... ... g);

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Num(42.0)) error: Unexpected token `numeric literal`. Expected yield, an identifier, [ or {
--> $DIR/tests/test262-parser/fail/364c1c6fe5df4e6c.js:1:15 --> $DIR/tests/test262-parser/fail/364c1c6fe5df4e6c.js:1:15
| |
1 | try {} catch (42) {} 1 | try {} catch (42) {}

View File

@ -1,4 +1,4 @@
error: Expected Comma, got Some(Dot) error: Expected ,, got Some(.)
--> $DIR/tests/test262-parser/fail/369676814db0cbbf.js:1:14 --> $DIR/tests/test262-parser/fail/369676814db0cbbf.js:1:14
| |
1 | ({set a({e: a.b}){}}) 1 | ({set a({e: a.b}){}})

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Semi) error: Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/39551fb86dcd3b29.js:1:21 --> $DIR/tests/test262-parser/fail/39551fb86dcd3b29.js:1:21
| |
1 | for (const let = 1;;;) {} 1 | for (const let = 1;;;) {}

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/3a3e59edfed719b0.js:1:1 --> $DIR/tests/test262-parser/fail/3a3e59edfed719b0.js:1:1
| |
1 | ({ obj:20 }) = 42 1 | ({ obj:20 }) = 42

View File

@ -1,4 +1,4 @@
error: Expected RBracket, got Some(Comma) error: Expected ], got Some(,)
--> $DIR/tests/test262-parser/fail/3a9fa392421db6dd.js:1:5 --> $DIR/tests/test262-parser/fail/3a9fa392421db6dd.js:1:5
| |
1 | ({[a,b]:0}) 1 | ({[a,b]:0})

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(RBrace) error: Unexpected token `}`. Expected identifier
--> $DIR/tests/test262-parser/fail/3bbeaf1dd9ca1159.js:1:6 --> $DIR/tests/test262-parser/fail/3bbeaf1dd9ca1159.js:1:6
| |
1 | ({ 5 }) => {} 1 | ({ 5 }) => {}

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Dot) error: Unexpected token `.`. Expected yield, an identifier, [ or {
--> $DIR/tests/test262-parser/fail/3f9ce9123e9ea7cb.js:1:14 --> $DIR/tests/test262-parser/fail/3f9ce9123e9ea7cb.js:1:14
| |
1 | function a([a.b]) {} 1 | function a([a.b]) {}

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(RBrace) error: Unexpected token `}`. Expected identifier
--> $DIR/tests/test262-parser/fail/4045c354c559bed0.js:1:4 --> $DIR/tests/test262-parser/fail/4045c354c559bed0.js:1:4
| |
1 | ({0} = 0) 1 | ({0} = 0)

View File

@ -1,4 +1,4 @@
error: Expected RBrace, got None error: Expected }, got None
--> $DIR/tests/test262-parser/fail/41895c8145489971.js:1:18 --> $DIR/tests/test262-parser/fail/41895c8145489971.js:1:18
| |
1 | `hello ${10 `test` 1 | `hello ${10 `test`

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(BinOp(Sub)) error: Unexpected token `-`. Expected yield, an identifier, [ or {
--> $DIR/tests/test262-parser/fail/420d5571366f2df6.js:1:15 --> $DIR/tests/test262-parser/fail/420d5571366f2df6.js:1:15
| |
1 | try {} catch (-x) {} 1 | try {} catch (-x) {}

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(RBracket) error: Unexpected token `]`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/42cb3f2a38cb2930.js:2:3 --> $DIR/tests/test262-parser/fail/42cb3f2a38cb2930.js:2:3
| |
2 | */] 2 | */]

View File

@ -1,4 +1,4 @@
error: TS1094 error: A `set` accessor must have a corresponding `get` accessor
--> $DIR/tests/test262-parser/fail/44dda972051e652d.js:1:11 --> $DIR/tests/test262-parser/fail/44dda972051e652d.js:1:11
| |
1 | class A { get prop(x) {} } 1 | class A { get prop(x) {} }

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(RBrace) error: Unexpected token `}`. Expected identifier, string literal, numeric literal or [ for the computed key
--> $DIR/tests/test262-parser/fail/45b295d6c9abe25d.js:1:6 --> $DIR/tests/test262-parser/fail/45b295d6c9abe25d.js:1:6
| |
1 | ({ * }) 1 | ({ * })

View File

@ -1,4 +1,4 @@
error: TS1094 error: A `set` accessor must have a corresponding `get` accessor
--> $DIR/tests/test262-parser/fail/45cb305cf7a07edd.js:1:8 --> $DIR/tests/test262-parser/fail/45cb305cf7a07edd.js:1:8
| |
1 | ({ set prop() {} }) 1 | ({ set prop() {} })

View File

@ -1,4 +1,4 @@
error: Expected LBrace, got Some(BinOp(Div)) error: Expected {, got Some(/)
--> $DIR/tests/test262-parser/fail/45db351b2b07663a.module.js:1:8 --> $DIR/tests/test262-parser/fail/45db351b2b07663a.module.js:1:8
| |
1 | export / from a 1 | export / from a

View File

@ -1,4 +1,4 @@
error: TS1005 error: Expected a semicolon
--> $DIR/tests/test262-parser/fail/48dee14b7a3a3767.module.js:1:19 --> $DIR/tests/test262-parser/fail/48dee14b7a3a3767.module.js:1:19
| |
1 | export let[a] = 0 export let[b] = 0 1 | export let[a] = 0 export let[b] = 0

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Semi) error: Unexpected token `;`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/49624f905645b7d0.js:1:24 --> $DIR/tests/test262-parser/fail/49624f905645b7d0.js:1:24
| |
1 | for (let x, y, z, let;;;) {} 1 | for (let x, y, z, let;;;) {}

View File

@ -1,4 +1,4 @@
error: Expected Semi, got Some(RParen) error: Expected ;, got Some())
--> $DIR/tests/test262-parser/fail/49861fa3ca0ffc30.js:1:15 --> $DIR/tests/test262-parser/fail/49861fa3ca0ffc30.js:1:15
| |
1 | for ((i in {})); 1 | for ((i in {}));

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Semi) error: Invalid access to super
--> $DIR/tests/test262-parser/fail/49edc77061449ae3.js:1:42 --> $DIR/tests/test262-parser/fail/49edc77061449ae3.js:1:42
| |
1 | class A extends B { constructor() { super; } } 1 | class A extends B { constructor() { super; } }

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Colon) error: Unexpected token `:`. Expected * for generator, private key, identifier or async
--> $DIR/tests/test262-parser/fail/4a866d4657f5a83a.js:1:12 --> $DIR/tests/test262-parser/fail/4a866d4657f5a83a.js:1:12
| |
1 | (class {[3]:0}) 1 | (class {[3]:0})

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(Word(if)) error: Unexpected token `if`. Expected this, import, async, function, [ for array literal, { for object literal, @ for decorator, function, class, null, true, false, number, bigint, string, regexp, ` for template literal, (, or an identifier
--> $DIR/tests/test262-parser/fail/4c3f75c2ad9dc102.js:1:11 --> $DIR/tests/test262-parser/fail/4c3f75c2ad9dc102.js:1:11
| |
1 | ({ set: s(if) { } }) 1 | ({ set: s(if) { } })

View File

@ -1,4 +1,4 @@
error: Expected Comma, got Some(Dot) error: Expected ,, got Some(.)
--> $DIR/tests/test262-parser/fail/4c7ea6a86bafaf0f.js:1:17 --> $DIR/tests/test262-parser/fail/4c7ea6a86bafaf0f.js:1:17
| |
1 | (function ({e: a.b}) {}) 1 | (function ({e: a.b}) {})

View File

@ -1,4 +1,4 @@
error: Expected Comma, got Some(Dot) error: Expected ,, got Some(.)
--> $DIR/tests/test262-parser/fail/4daec155c0322d5e.js:1:17 --> $DIR/tests/test262-parser/fail/4daec155c0322d5e.js:1:17
| |
1 | function a({e: a.b}) {} 1 | function a({e: a.b}) {}

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(RParen) error: Invalid access to super
--> $DIR/tests/test262-parser/fail/4ee75fab1ccee715.js:1:16 --> $DIR/tests/test262-parser/fail/4ee75fab1ccee715.js:1:16
| |
1 | ({ a() { (super).b(); } }); 1 | ({ a() { (super).b(); } });

View File

@ -1,4 +1,4 @@
error: Expected RBracket, got None error: Expected ], got None
--> $DIR/tests/test262-parser/fail/4ee7b10cd97f554c.js:1:2 --> $DIR/tests/test262-parser/fail/4ee7b10cd97f554c.js:1:2
| |
1 | [, 1 | [,

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/4f0b15bd78646107.js:1:1 --> $DIR/tests/test262-parser/fail/4f0b15bd78646107.js:1:1
| |
1 | 1-- 1 | 1--

View File

@ -1,4 +1,4 @@
error: Unexpected token Some(LParen) error: Unexpected token `(`. Expected identifier, string literal, numeric literal or [ for the computed key
--> $DIR/tests/test262-parser/fail/4f6d3aaae5c7ad56.js:1:6 --> $DIR/tests/test262-parser/fail/4f6d3aaae5c7ad56.js:1:6
| |
1 | var {(a)} = 0 1 | var {(a)} = 0

View File

@ -1,4 +1,4 @@
error: TS1005 error: Expected a semicolon
--> $DIR/tests/test262-parser/fail/525c5220320e32ee.js:1:8 --> $DIR/tests/test262-parser/fail/525c5220320e32ee.js:1:8
| |
1 | try { } 1 | try { }

View File

@ -1,4 +1,4 @@
error: TS1009 error: Trailing comma is not allowed
--> $DIR/tests/test262-parser/fail/52a2eb6caebf1bf7.js:1:6 --> $DIR/tests/test262-parser/fail/52a2eb6caebf1bf7.js:1:6
| |
1 | var x, 1 | var x,

View File

@ -1,4 +1,4 @@
error: Expected Comma, got Some(Dot) error: Expected ,, got Some(.)
--> $DIR/tests/test262-parser/fail/537c4a516d7c8d7f.js:1:20 --> $DIR/tests/test262-parser/fail/537c4a516d7c8d7f.js:1:20
| |
1 | try {} catch ({e: x.a}) {} 1 | try {} catch ({e: x.a}) {}

View File

@ -1,4 +1,4 @@
error: TS1094 error: A `set` accessor must have a corresponding `get` accessor
--> $DIR/tests/test262-parser/fail/576b2243fb8c3b54.js:1:8 --> $DIR/tests/test262-parser/fail/576b2243fb8c3b54.js:1:8
| |
1 | ({ get prop(x) {} }) 1 | ({ get prop(x) {} })

View File

@ -1,4 +1,4 @@
error: TS2406 error: Invalid left-hand side in 'for...in' statement
--> $DIR/tests/test262-parser/fail/581bedbbce2541be.js:1:6 --> $DIR/tests/test262-parser/fail/581bedbbce2541be.js:1:6
| |
1 | for (i + 1 in {}); 1 | for (i + 1 in {});

Some files were not shown because too many files have changed in this diff Show More