Skip to content

Commit d75495e

Browse files
authored
Merge branch 'WerWolv:master' into new_lexer
2 parents 0e7758e + 7908b49 commit d75495e

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ namespace pl::core::ast {
5252
if (this->m_placementSection != nullptr) {
5353
const auto node = this->m_placementSection->evaluate(evaluator);
5454
const auto id = dynamic_cast<ASTNodeLiteral *>(node.get());
55-
if (id == nullptr)
55+
if (id == nullptr) {
56+
scopeGuard.release();
5657
err::E0010.throwError("Cannot use void expression as section identifier.", {}, this->getLocation());
58+
}
5759

5860
evaluator->pushSectionId(u64(id->getValue().toUnsigned()));
5961
} else {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ namespace pl::core::ast {
3636
if (this->m_placementSection != nullptr) {
3737
const auto node = this->m_placementSection->evaluate(evaluator);
3838
const auto id = dynamic_cast<ASTNodeLiteral *>(node.get());
39-
if (id == nullptr)
39+
if (id == nullptr) {
40+
scopeGuard.release();
4041
err::E0010.throwError("Cannot use void expression as section identifier.", {}, this->getLocation());
42+
}
4143

4244
evaluator->pushSectionId(u64(id->getValue().toUnsigned()));
4345
} else {
@@ -89,9 +91,11 @@ namespace pl::core::ast {
8991

9092
std::vector<std::shared_ptr<ptrn::Pattern>> pointedAtPatterns;
9193
ON_SCOPE_EXIT {
92-
auto &pointedAtPattern = pointedAtPatterns.front();
94+
if (!pointedAtPatterns.empty()) {
95+
auto &pointedAtPattern = pointedAtPatterns.front();
96+
pattern->setPointedAtPattern(std::move(pointedAtPattern));
97+
}
9398

94-
pattern->setPointedAtPattern(std::move(pointedAtPattern));
9599
pattern->setSection(evaluator->getSectionId());
96100
};
97101

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ namespace pl::core::ast {
3737
if (this->m_placementSection != nullptr) {
3838
const auto node = this->m_placementSection->evaluate(evaluator);
3939
const auto id = dynamic_cast<ASTNodeLiteral *>(node.get());
40-
if (id == nullptr)
40+
if (id == nullptr) {
41+
scopeGuard.release();
4142
err::E0002.throwError("Cannot use void expression as section identifier.", {}, this->getLocation());
43+
}
4244

4345
evaluator->pushSectionId((u64)id->getValue().toUnsigned());
4446
} else {

lib/source/pl/core/evaluator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,9 @@ namespace pl::core {
937937
}
938938

939939
void Evaluator::popSectionId() {
940+
if (this->m_sectionIdStack.empty())
941+
return;
942+
940943
this->m_sectionIdStack.pop_back();
941944
}
942945

0 commit comments

Comments
 (0)