better error messages

This commit is contained in:
r4
2021-12-25 12:32:52 +01:00
parent f02dae603d
commit b58810e822
5 changed files with 24 additions and 5 deletions

View File

@@ -35,7 +35,7 @@ Value eval_binary(IRInstr instr, const Value *lhs, const Value *rhs) {
.Float = res,
};
} else {
set_err("Unsupported types for operation '%s'", irinstr_str[instr]);
set_err("Unsupported types for operation '%s': %s and %s", irinstr_str[instr], type_str[lhs->type.kind], type_str[rhs->type.kind]);
return (Value){0};
}
}
@@ -58,7 +58,7 @@ Value eval_binary(IRInstr instr, const Value *lhs, const Value *rhs) {
default: ASSERT_UNREACHED();
};
} else {
set_err("Unsupported types for operation '%s'", irinstr_str[instr]);
set_err("Unsupported types for operation '%s': %s and %s", irinstr_str[instr], type_str[lhs->type.kind], type_str[rhs->type.kind]);
return (Value){0};
}
return (Value){
@@ -93,14 +93,14 @@ Value eval_unary(IRInstr instr, const Value *v) {
else if (v->type.kind == TypeFloat)
return (Value){ .type.kind = TypeFloat, .Float = -v->Float };
else {
set_err("Unsupported type for operation '%s'", irinstr_str[instr]);
set_err("Unsupported type for operation '%s': %s", irinstr_str[instr], type_str[v->type.kind]);
return (Value){0};
}
case IRNot:
if (v->type.kind == TypeBool) {
return (Value){ .type.kind = TypeBool, .Bool = !v->Bool };
} else {
set_err("Unsupported type for operation '%s'", irinstr_str[instr]);
set_err("Unsupported type for operation '%s': %s", irinstr_str[instr], type_str[v->type.kind]);
return (Value){0};
}
default: