feat(selfhost-sema): arithmetic errors return tyUnknown sentinel
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[Package]
|
||||
Name = "error_recovery"
|
||||
Version = "0.1.0"
|
||||
Type = "bin"
|
||||
|
||||
[Build]
|
||||
Output = "Bin"
|
||||
@@ -0,0 +1,5 @@
|
||||
func Main() -> int {
|
||||
let bad: int = "a" + 1;
|
||||
let z: int = undefined_variable;
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user