Skip to content

Commit 7eefb5c

Browse files
authored
evaluator: Fix strict weak ordering (WerWolv#164)
1 parent 6b3b402 commit 7eefb5c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/source/pl/core/token.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ namespace pl::core {
112112

113113
std::strong_ordering Token::Literal::operator<=>(const Literal &other) const {
114114
return std::visit(wolv::util::overloaded {
115+
[](std::shared_ptr<ptrn::Pattern> lhs, std::shared_ptr<ptrn::Pattern> rhs) {
116+
return lhs->getOffset() <=> rhs->getOffset();
117+
},
115118
[]<typename T>(T lhs, T rhs) -> std::strong_ordering {
116119
if (lhs == rhs) return std::strong_ordering::equal;
117120
if (lhs < rhs) return std::strong_ordering::less;
@@ -158,7 +161,7 @@ namespace pl::core {
158161
}
159162
},
160163
[](auto, auto) -> std::strong_ordering {
161-
return std::strong_ordering::less;
164+
return std::strong_ordering::equal;
162165
}
163166
}, *this, other);
164167
}

0 commit comments

Comments
 (0)