aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/ControlFlowGen.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-18 06:05:53 +0000
committer_ov4 <ov4@ov4.org>2026-10-18 06:05:53 +0000
commit16231050058131860f710073c17d3bca7c6637eb (patch)
tree1da2ca606f1d513822ccd04b3053d5eee69ac19d /lib/CodeGen/ControlFlowGen.cc
parent1b0b287629e6e3b6d8eb6182db72b28fd0510574 (diff)
feat(operators): support global binary operator overloads
Resolve exact operand types and preserve declared operator return types. Reject implicit STRING to BOOLEAN conversion at typed expression boundaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ControlFlowGen.cc')
-rw-r--r--lib/CodeGen/ControlFlowGen.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/CodeGen/ControlFlowGen.cc b/lib/CodeGen/ControlFlowGen.cc
index 17f43f2..0cf0c34 100644
--- a/lib/CodeGen/ControlFlowGen.cc
+++ b/lib/CodeGen/ControlFlowGen.cc
@@ -204,6 +204,14 @@ void CodeGen::emitCaseStmt(CaseStmtAST *Stmt) {
return nullptr;
}
Value *LabelValue = emitExpr(Label);
+ auto Overload = resolveOperator(Op, SelectorType, LabelType);
+ if (Overload.Signature && !Overload.Ambiguous) {
+ const TypeInfo *Result = resolveType(Overload.Signature->ReturnTypeName);
+ if (!Result || Result->Kind != TypeKind::Boolean) {
+ reportError("CASE comparison must return BOOLEAN");
+ return nullptr;
+ }
+ }
return emitBinaryOp(Op, Selected, SelectorType, LabelValue, LabelType, Branch.Line);
};
if (!Branch.Lower) {