From: Brendan Hansen Date: Sat, 13 Nov 2021 01:47:25 +0000 (-0600) Subject: bugfixes and added assertions X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=0020a621c0f7e29ee95af3da0856ea040509f446;p=onyx.git bugfixes and added assertions --- diff --git a/core/container/iter.onyx b/core/container/iter.onyx index dc04d67f..8015be0c 100644 --- a/core/container/iter.onyx +++ b/core/container/iter.onyx @@ -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; diff --git a/docs/bugs b/docs/bugs index cd9f19e5..3b8f0cf7 100644 --- 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 diff --git a/src/astnodes.c b/src/astnodes.c index 98a84e49..0c7246a6 100644 --- a/src/astnodes.c +++ b/src/astnodes.c @@ -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] = { diff --git a/src/errors.c b/src/errors.c index 8276f0a7..71fa50d1 100644 --- a/src/errors.c +++ b/src/errors.c @@ -76,6 +76,8 @@ b32 onyx_has_errors() { } void onyx_clear_errors() { + if (context.cycle_detected) return; + bh_arr_set_length(errors.errors, 0); } diff --git a/src/onyx.c b/src/onyx.c index 522e6647..3182ab6b 100644 --- a/src/onyx.c +++ b/src/onyx.c @@ -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; diff --git a/src/wasm_output.c b/src/wasm_output.c index ceb2093a..8cfbfeb4 100644 --- a/src/wasm_output.c +++ b/src/wasm_output.c @@ -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);