From 218b4715ca7366f3a70980d839ff6156841417df Mon Sep 17 00:00:00 2001 From: Iban Eguia Date: Tue, 20 Oct 2020 19:41:14 +0200 Subject: [PATCH] Added "unimplemented" syntax errors (#901) --- boa/src/syntax/parser/error.rs | 17 +++++++++++++++++ .../parser/statement/iteration/for_statement.rs | 7 +++++-- test262 | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/boa/src/syntax/parser/error.rs b/boa/src/syntax/parser/error.rs index 5868b92d7e..6d16535def 100644 --- a/boa/src/syntax/parser/error.rs +++ b/boa/src/syntax/parser/error.rs @@ -46,6 +46,11 @@ pub enum ParseError { message: &'static str, position: Position, }, + /// Unimplemented syntax error + Unimplemented { + message: &'static str, + position: Position, + }, } impl ParseError { @@ -91,6 +96,11 @@ impl ParseError { pub(super) fn lex(e: LexError) -> Self { Self::Lex { err: e } } + + /// Creates a new `Unimplemented` parsing error. + pub(super) fn unimplemented(message: &'static str, position: Position) -> Self { + Self::Unimplemented { message, position } + } } impl fmt::Display for ParseError { @@ -156,6 +166,13 @@ impl fmt::Display for ParseError { position.column_number() ), Self::Lex { err } => fmt::Display::fmt(err, f), + Self::Unimplemented { message, position } => write!( + f, + "{} not yet implemented at line {}, col {}", + message, + position.line_number(), + position.column_number() + ), } } } diff --git a/boa/src/syntax/parser/statement/iteration/for_statement.rs b/boa/src/syntax/parser/statement/iteration/for_statement.rs index 0c388c8853..8b87b77128 100644 --- a/boa/src/syntax/parser/statement/iteration/for_statement.rs +++ b/boa/src/syntax/parser/statement/iteration/for_statement.rs @@ -88,10 +88,13 @@ where _ => Some(Expression::new(true, self.allow_yield, self.allow_await).parse(cursor)?), }; - // TODO: for..in, for..of match cursor.peek(0)? { Some(tok) if tok.kind() == &TokenKind::Keyword(Keyword::In) => { - unimplemented!("for...in statement") + // TODO: for...in + return Err(ParseError::unimplemented( + "for...in loops", + tok.span().start(), + )); } Some(tok) if tok.kind() == &TokenKind::Keyword(Keyword::Of) && init.is_some() => { let _ = cursor.next(); diff --git a/test262 b/test262 index 3439564fca..0e7319c015 160000 --- a/test262 +++ b/test262 @@ -1 +1 @@ -Subproject commit 3439564fcac38845669c8488d68f3d16965a7852 +Subproject commit 0e7319c015fe935594f8bcafaedb0c94f7fec1df