bugfixes and added assertions
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 13 Nov 2021 01:47:25 +0000 (19:47 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Sat, 13 Nov 2021 01:47:25 +0000 (19:47 -0600)
core/container/iter.onyx
docs/bugs
src/astnodes.c
src/errors.c
src/onyx.c
src/wasm_output.c

index dc04d67fae8d053a85778e79068d2e95b079216f..8015be0c841a061acf5bfb968ad2108e540fb89a 100644 (file)
@@ -338,7 +338,7 @@ from_array :: (arr: [] $T) -> Iterator(^T) {
     }
 
     next :: (use c: ^Context) -> (i32, bool) {
-        if v > r.high {
+        if v >= r.high {
             return 0, false;
         } else {
             defer v += r.step;
index cd9f19e5f84c523e33250fb375a03eed20291dad..3b8f0cf710a7ce93e79b8b49834433e209081cab 100644 (file)
--- a/docs/bugs
+++ b/docs/bugs
@@ -8,8 +8,21 @@ List of known bugs:
         println(x); // Doesn't work
     }
 
+[ ] I don't know why this doesn't work... It is complaining that it couldn't match
+    either of these cases, but if I remove the first, it matches the second. This
+    is clearly wrong behavior, but I don't immediately see where the problem is.
+
+    CanCastTo :: interface (T: type_expr, D: type_expr) {
+        cast(typeof D) T;
+    }
+
+    cast_able :: #match {
+        (_: $T, $D: type_expr) -> bool where CanCastTo(T, D) do return true; ,
+        (_: any, d: type_expr) -> bool { return false; },
+    }
+
 [X] Memory reservation type checking doesn't work how I think it should. This errors for example:
-    
+
     x: i64 = 1;
 
 [X] Initialization statements on control statements should be better. For example, this should
index 98a84e49902c81dd9be2dd8f1832d8570d975bea..0c7246a6f24379beea446febf96e07e67ea7024c 100644 (file)
@@ -130,8 +130,8 @@ const char* entity_state_strings[Entity_State_Count] = {
     "Resolve Symbols",
     "Check Types",
     "Code Gen",
-    "Failed",
     "Finalized",
+    "Failed",
 };
 
 const char* entity_type_strings[Entity_Type_Count] = {
index 8276f0a73252ff6d06f87c2c31f244f6192c4dc6..71fa50d1cfda3ea29db2fdc109aedb969b29f9df 100644 (file)
@@ -76,6 +76,8 @@ b32 onyx_has_errors() {
 }
 
 void onyx_clear_errors() {
+    if (context.cycle_detected) return;
+
     bh_arr_set_length(errors.errors, 0);
 }
 
index 522e664723f205cb8ea3f357f801a5ab55e55d15..3182ab6ba15a70b92efa3f12b1aa886ca2139944 100644 (file)
@@ -386,8 +386,8 @@ static b32 process_entity(Entity* ent) {
 
     b32 changed = ent->state != before_state;
     if (context.options->verbose_output == 3) {
-        if (changed) printf("SUCCESS | %s", verbose_output_buffer);
-        else         printf("YIELD   | %s", verbose_output_buffer);
+        if (changed) printf("SUCCESS to %20s | %s", entity_state_strings[ent->state], verbose_output_buffer);
+        else         printf("YIELD   to %20s | %s", entity_state_strings[ent->state], verbose_output_buffer);
     }
 
     return changed;
index ceb2093a5279deb7d868c5b4aee99c661a60c914..8cfbfeb4dbd64c3c34643cd1d1679eab7dbcd885 100644 (file)
@@ -408,6 +408,7 @@ static void output_instruction(WasmFunc* func, WasmInstruction* instr, bh_buffer
     u8* leb;
 
     if (instr->type == WI_NOP) return;
+    if (instr->type == WI_UNREACHABLE) assert(("EMITTING UNREACHABLE!!", 0));
 
     if (instr->type & SIMD_INSTR_MASK) {
         bh_buffer_write_byte(buff, 0xFD);
@@ -553,6 +554,8 @@ static i32 output_code(WasmFunc* func, bh_buffer* buff) {
     // Output locals
     output_locals(func, &code_buff);
 
+    assert(func->code);
+
     // Output code
     bh_arr_each(WasmInstruction, instr, func->code) output_instruction(func, instr, &code_buff);