From 535927a85ea9a5c22ba5949da7a1f26dc4d4fe3d Mon Sep 17 00:00:00 2001 From: Brian Carroll Date: Mon, 10 Jan 2022 09:58:41 +0000 Subject: [PATCH] Wasm: fix test_wrapper function index --- compiler/test_gen/src/helpers/wasm32_test_result.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/test_gen/src/helpers/wasm32_test_result.rs b/compiler/test_gen/src/helpers/wasm32_test_result.rs index e76581eefa..34e2a86bea 100644 --- a/compiler/test_gen/src/helpers/wasm32_test_result.rs +++ b/compiler/test_gen/src/helpers/wasm32_test_result.rs @@ -14,8 +14,9 @@ pub trait Wasm32TestResult { wrapper_name: &str, main_function_index: u32, ) { - // Assumes the main function was the first one to be generated - let index = main_function_index + module.code.code_builders.len() as u32; + let index = module.import.function_count() + + module.code.preloaded_count + + module.code.code_builders.len() as u32; module.add_function_signature(Signature { param_types: Vec::with_capacity_in(0, arena),