From 132aa8772fb7e668e223d9325449ff9b424ba9dc Mon Sep 17 00:00:00 2001 From: Iban Eguia Moraza Date: Tue, 20 Oct 2020 14:29:51 +0200 Subject: [PATCH 1/3] Added "unimplemented" syntax errors --- boa/src/syntax/parser/error.rs | 17 +++++++++++++++++ .../parser/statement/iteration/for_statement.rs | 7 +++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/boa/src/syntax/parser/error.rs b/boa/src/syntax/parser/error.rs index 5868b92d7e6..6d16535def8 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 0c388c8853e..a24fd9394cc 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"), + cursor.position(), + ); } Some(tok) if tok.kind() == &TokenKind::Keyword(Keyword::Of) && init.is_some() => { let _ = cursor.next(); From 508a64b640bc5d88ef24b7e570280e0732fe99e0 Mon Sep 17 00:00:00 2001 From: Iban Eguia Moraza Date: Tue, 20 Oct 2020 14:39:10 +0200 Subject: [PATCH 2/3] Fix a couple of syntax errors --- .../syntax/parser/statement/iteration/for_statement.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boa/src/syntax/parser/statement/iteration/for_statement.rs b/boa/src/syntax/parser/statement/iteration/for_statement.rs index a24fd9394cc..8b87b771288 100644 --- a/boa/src/syntax/parser/statement/iteration/for_statement.rs +++ b/boa/src/syntax/parser/statement/iteration/for_statement.rs @@ -91,10 +91,10 @@ where match cursor.peek(0)? { Some(tok) if tok.kind() == &TokenKind::Keyword(Keyword::In) => { // TODO: for...in - return Err( - ParseError::unimplemented("for...in loops"), - cursor.position(), - ); + 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(); From 7d902540679d05e8d5f3eb39c3c36807df5cefb8 Mon Sep 17 00:00:00 2001 From: Iban Eguia Moraza Date: Tue, 20 Oct 2020 14:44:50 +0200 Subject: [PATCH 3/3] Updated the Test262 suite --- test262 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test262 b/test262 index 3439564fcac..0e7319c015f 160000 --- a/test262 +++ b/test262 @@ -1 +1 @@ -Subproject commit 3439564fcac38845669c8488d68f3d16965a7852 +Subproject commit 0e7319c015fe935594f8bcafaedb0c94f7fec1df