mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:47:35 +00:00
LibJS: Add support for binding patterns in catch clauses
`try { ... } catch({a=foo}) {}` is valid, and now we parse and evaluate it correctly :^)
This commit is contained in:
parent
1a9518ebe3
commit
77a5144264
4 changed files with 73 additions and 15 deletions
|
@ -1303,14 +1303,21 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
FlyString const& parameter() const { return m_parameter; }
|
||||
CatchClause(SourceRange source_range, NonnullRefPtr<BindingPattern> parameter, NonnullRefPtr<BlockStatement> body)
|
||||
: ASTNode(source_range)
|
||||
, m_parameter(move(parameter))
|
||||
, m_body(move(body))
|
||||
{
|
||||
}
|
||||
|
||||
auto& parameter() const { return m_parameter; }
|
||||
BlockStatement const& body() const { return m_body; }
|
||||
|
||||
virtual void dump(int indent) const override;
|
||||
virtual Value execute(Interpreter&, GlobalObject&) const override;
|
||||
|
||||
private:
|
||||
FlyString m_parameter;
|
||||
Variant<FlyString, NonnullRefPtr<BindingPattern>> m_parameter;
|
||||
NonnullRefPtr<BlockStatement> m_body;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue