From aa571577253ccfc88a9adb5b46b1b7448e3b9669 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 26 Sep 2022 21:36:29 -0500 Subject: [PATCH] bugfix with field accesses in interfaces --- compiler/src/checker.c | 8 +++++++- compiler/src/wasm_output.h | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/src/checker.c b/compiler/src/checker.c index b81cbbe9..ddc3977b 100644 --- a/compiler/src/checker.c +++ b/compiler/src/checker.c @@ -1753,7 +1753,12 @@ CheckStatus check_field_access(AstFieldAccess** pfield) { return Check_Success; } - if (!context.cycle_detected) { + // + // This has to be cycle_almost_detected, not cycle_detected, because interface + // constraints relay on Check_Error being returned, not Check_Yield_Macro. For + // this reason, I have to produce an error at the last minute, BEFORE the loop + // enters a cycle detected state, when there is no point of return. + if (!context.cycle_almost_detected) { // Skipping the slightly expensive symbol lookup // below by not using YIELD_ERROR. return Check_Yield_Macro; @@ -2878,6 +2883,7 @@ CheckStatus check_constraint(AstConstraint *constraint) { CheckStatus cs = check_expression(&ic->expr); if (cs == Check_Return_To_Symres || cs == Check_Yield_Macro) { + onyx_clear_errors(); return cs; } diff --git a/compiler/src/wasm_output.h b/compiler/src/wasm_output.h index 74213c57..f03eb6b3 100644 --- a/compiler/src/wasm_output.h +++ b/compiler/src/wasm_output.h @@ -722,6 +722,7 @@ static i32 output_onyx_libraries_section(OnyxWasmModule* module, bh_buffer* buff return buff->length - prev_len; } +/* static i32 output_onyx_func_offset_section(OnyxWasmModule* module, bh_buffer* buff) { i32 prev_len = buff->length; @@ -762,6 +763,7 @@ static i32 output_onyx_func_offset_section(OnyxWasmModule* module, bh_buffer* bu return buff->length - prev_len; } +*/ #ifdef ENABLE_DEBUG_INFO static i32 output_ovm_debug_sections(OnyxWasmModule* module, bh_buffer* buff) { @@ -1050,7 +1052,7 @@ void onyx_wasm_module_write_to_buffer(OnyxWasmModule* module, bh_buffer* buffer) // TODO: Consider if this should always be included? // It can amount to a lot of extra data. - output_onyx_func_offset_section(module, buffer); + // output_onyx_func_offset_section(module, buffer); } void onyx_wasm_module_write_to_file(OnyxWasmModule* module, bh_file file) { -- 2.25.1