summaryrefslogtreecommitdiff
path: root/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 0430cbd..cf74f39 100644
--- a/eval.c
+++ b/eval.c
@@ -236,6 +236,13 @@ static void u64_to_val(Value *v, BuiltinType v_type, U64 x) {
static bool val_is_nonnegative(Value *v, Type *t) {
assert(t->kind == TYPE_BUILTIN);
+ switch (t->builtin) {
+ case BUILTIN_BOOL: assert(0); return false;
+ case BUILTIN_CHAR: return v->charv >= 0;
+ case BUILTIN_F32: return v->f32 >= 0;
+ case BUILTIN_F64: return v->f64 >= 0;
+ default: break;
+ }
if (!type_builtin_is_signed(t->builtin))
return true;
return val_to_i64(v, t->builtin) >= 0;