diff --git a/ets2panda/ir/base/catchClause.cpp b/ets2panda/ir/base/catchClause.cpp index c4c120f155080943daee24380056624657f225c6..c11433d958f4954e280b5d414698c2ff1e6ec797 100644 --- a/ets2panda/ir/base/catchClause.cpp +++ b/ets2panda/ir/base/catchClause.cpp @@ -98,11 +98,13 @@ CatchClause::CatchClause(CatchClause const &other, ArenaAllocator *allocator) : { param_ = nullptr; body_ = nullptr; - if (other.param_ != nullptr && other.param_->Clone(allocator, this) != nullptr) { - param_ = other.param_->Clone(allocator, this)->AsExpression(); + auto *const cloneParam = other.param_ != nullptr ? other.param_->Clone(allocator, this) : nullptr; + auto *const cloneBody = other.body_ != nullptr ? other.body_->Clone(allocator, this) : nullptr; + if (cloneParam != nullptr) { + param_ = cloneParam->AsExpression(); } - if (other.body_ != nullptr && other.body_->Clone(allocator, this) != nullptr) { - body_ = other.body_->Clone(allocator, this)->AsBlockStatement(); + if (cloneBody != nullptr) { + body_ = cloneBody->AsBlockStatement(); } } diff --git a/ets2panda/parser/ETSparserExpressions.cpp b/ets2panda/parser/ETSparserExpressions.cpp index 55bb39d44320491808843b0c7cb6227eadc1eb35..40d3293cb5d63337132454f7f271850e943f3b1a 100644 --- a/ets2panda/parser/ETSparserExpressions.cpp +++ b/ets2panda/parser/ETSparserExpressions.cpp @@ -249,6 +249,7 @@ ir::Expression *ETSParser::ParsePropertyKey([[maybe_unused]] ExpressionParseFlag case lexer::TokenType::LITERAL_IDENT: { const util::StringView &ident = Lexer()->GetToken().Ident(); key = AllocNode(ident, Allocator()); + ES2PANDA_ASSERT(key != nullptr); key->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); return key; @@ -256,6 +257,7 @@ ir::Expression *ETSParser::ParsePropertyKey([[maybe_unused]] ExpressionParseFlag case lexer::TokenType::LITERAL_STRING: { const util::StringView &string = Lexer()->GetToken().String(); key = AllocNode(string); + ES2PANDA_ASSERT(key != nullptr); key->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); return key; @@ -266,6 +268,7 @@ ir::Expression *ETSParser::ParsePropertyKey([[maybe_unused]] ExpressionParseFlag } else { key = AllocNode(Lexer()->GetToken().GetNumber()); } + ES2PANDA_ASSERT(key != nullptr); key->SetRange(Lexer()->GetToken().Loc()); Lexer()->NextToken(); return key;