tiny bugfixes
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 8 Oct 2022 01:32:11 +0000 (20:32 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 8 Oct 2022 01:32:11 +0000 (20:32 -0500)
compiler/src/wasm_emit.c
core/container/iter.onyx

index 6978c6ddcfc597e5556906dcb2ae3c0097c3eaa0..21e3693936b212d748e1fbb8b29d71b482a6a3ca 100644 (file)
@@ -1619,6 +1619,10 @@ EMIT_FUNC(switch, AstSwitch* switch_node) {
             WID(switch_node->expr->token, WI_BLOCK_START, 0x40);
             emit_expression(mod, &code, switch_node->expr);
             if (switch_node->min_case != 0) {
+                if (onyx_type_to_wasm_type(switch_node->expr->type) == WASM_TYPE_INT64) {
+                    WI(switch_node->expr->token, WI_I32_FROM_I64);
+                }
+
                 WID(switch_node->expr->token, WI_I32_CONST, switch_node->min_case);
                 WI(switch_node->expr->token, WI_I32_SUB);
             }
index b3516fdcc6e622f7c03d57fcfd29dbe15925bd68..d490e7a934a18cb5c182056e753a7e40d75b1713 100644 (file)
@@ -9,7 +9,9 @@ Iterable :: interface (t: $T) {
 }
 
 close :: (it: Iterator($T)) {
-    it.close(it.data);
+    if it.close != null_proc {
+        it.close(it.data);
+    }
 }
 
 filter :: #match #local {}