diff --git a/Base/home/anon/js/string-length.js b/Base/home/anon/js/string-length.js index db20e7c955c..38b1ed191b9 100644 --- a/Base/home/anon/js/string-length.js +++ b/Base/home/anon/js/string-length.js @@ -1,3 +1 @@ -function foo() { - "hello friends".length -} +"hello friends".length diff --git a/Libraries/LibJS/Parser.cpp b/Libraries/LibJS/Parser.cpp index b9467cebd3a..24c4f58549d 100644 --- a/Libraries/LibJS/Parser.cpp +++ b/Libraries/LibJS/Parser.cpp @@ -132,6 +132,9 @@ NonnullOwnPtr Parser::parse_secondary_expression(NonnullOwnPtr(AssignmentOp::Assign, move(lhs), parse_expression()); + case TokenType::Period: + consume(); + return make(move(lhs), parse_expression()); default: m_has_errors = true; expected("secondary expression (missing switch case)"); @@ -239,7 +242,8 @@ bool Parser::match_secondary_expression() const || type == TokenType::Asterisk || type == TokenType::Slash || type == TokenType::Equals - || type == TokenType::ParenOpen; + || type == TokenType::ParenOpen + || type == TokenType::Period; } bool Parser::match_statement() const