feat(selfhost-sema): arithmetic errors return tyUnknown sentinel

This commit is contained in:
2026-07-28 20:33:21 +03:00
parent 44ecbd6873
commit 76ea9cc083
3 changed files with 13 additions and 1 deletions
+7
View File
@@ -0,0 +1,7 @@
[Package]
Name = "error_recovery"
Version = "0.1.0"
Type = "bin"
[Build]
Output = "Bin"
+5
View File
@@ -0,0 +1,5 @@
func Main() -> int {
let bad: int = "a" + 1;
let z: int = undefined_variable;
return 0;
}
+1 -1
View File
@@ -966,7 +966,7 @@ module Sema {
if op == tkAmpAmp || op == tkPipePipe || op == tkBang { return tyBool; }
// Arithmetic returns wider type
if !Sema_IsNumeric(left) || !Sema_IsNumeric(right) {
Sema_EmitError(sema, expr.line, expr.column, "arithmetic requires numeric operands");
return Sema_EmitExprError(sema, expr, "arithmetic requires numeric operands");
}
if left == tyFloat64 || right == tyFloat64 { return tyFloat64; }
return tyInt;