bugfix with field accesses in interfaces
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 27 Sep 2022 02:36:29 +0000 (21:36 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 27 Sep 2022 02:36:29 +0000 (21:36 -0500)
compiler/src/checker.c
compiler/src/wasm_output.h

index b81cbbe962a9ab113921724a30ae964c9dca5559..ddc3977b68dd8a61804cf09a618d57054539cf51 100644 (file)
@@ -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;
                 }
 
index 74213c576c83e7e95342d73e4e3751231e0824e6..f03eb6b37cf7967770264ba6e8492cfc7cad1bd7 100644 (file)
@@ -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) {