Skip to content

Commit 282ae3c

Browse files
committed
evaluator: Fix nullptr ending up in pattern tree if error gets thrown during array creation
1 parent d3fc097 commit 282ae3c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/source/pl/core/ast/ast_node_array_variable_decl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace pl::core::ast {
7878
} else {
7979
auto type = this->m_type->getTypeDefinition(evaluator);
8080

81-
auto &pattern = resultPatterns.emplace_back();
81+
std::shared_ptr<ptrn::Pattern> pattern;
8282
if (auto builtinType = dynamic_cast<const ASTNodeBuiltinType *>(type); builtinType != nullptr && builtinType->getType() != Token::ValueType::CustomType)
8383
createStaticArray(evaluator, pattern);
8484
else {
@@ -102,7 +102,8 @@ namespace pl::core::ast {
102102

103103
if (this->m_placementSection != nullptr && !evaluator->isGlobalScope()) {
104104
evaluator->addPattern(std::move(pattern));
105-
resultPatterns.pop_back();
105+
} else {
106+
resultPatterns.emplace_back(std::move(pattern));
106107
}
107108
}
108109
}

0 commit comments

Comments
 (0)