1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:47:46 +00:00

LibJS: Allow 'name = value' in object literals as the spec does

Currently, these are _always_ a syntax error, future commits will make
it valid in certain contexts.
This commit is contained in:
Ali Mohammad Pur 2021-07-11 14:48:30 +04:30 committed by Linus Groh
parent 7dae25eceb
commit 7fc6cd6b20
2 changed files with 28 additions and 4 deletions

View file

@ -1134,9 +1134,10 @@ private:
class ObjectExpression final : public Expression {
public:
explicit ObjectExpression(SourceRange source_range, NonnullRefPtrVector<ObjectProperty> properties = {})
explicit ObjectExpression(SourceRange source_range, NonnullRefPtrVector<ObjectProperty> properties = {}, Optional<SourceRange> first_invalid_property_range = {})
: Expression(source_range)
, m_properties(move(properties))
, m_first_invalid_property_range(move(first_invalid_property_range))
{
}
@ -1144,8 +1145,11 @@ public:
virtual void dump(int indent) const override;
virtual void generate_bytecode(Bytecode::Generator&) const override;
Optional<SourceRange> const& invalid_property_range() const { return m_first_invalid_property_range; }
private:
NonnullRefPtrVector<ObjectProperty> m_properties;
Optional<SourceRange> m_first_invalid_property_range;
};
class ArrayExpression final : public Expression {