Browse Source

Allow boolean/null as property identifier by dot operator assignment (#1985)

This Pull Request lets true/false/null be used as object property identifiers, when using dot assignment.

`foo.null = 'bar';`

It changes the following:

- AST parsing of member expressions
pull/1986/head
lupd 3 years ago
parent
commit
405038d140
  1. 15
      boa_engine/src/syntax/parser/expression/left_hand_side/member.rs

15
boa_engine/src/syntax/parser/expression/left_hand_side/member.rs

@ -99,6 +99,21 @@ where
TokenKind::Keyword(kw) => {
lhs = GetConstField::new(lhs, kw.to_sym(interner)).into();
}
TokenKind::BooleanLiteral(bool) => {
match bool {
true => {
lhs = GetConstField::new(lhs, Keyword::True.to_sym(interner))
.into();
}
false => {
lhs = GetConstField::new(lhs, Keyword::False.to_sym(interner))
.into();
}
};
}
TokenKind::NullLiteral => {
lhs = GetConstField::new(lhs, Keyword::Null.to_sym(interner)).into();
}
_ => {
return Err(ParseError::expected(
["identifier".to_owned()],

Loading…
Cancel
Save