From d8d7596f813bf59138ca89929575f02923b46375 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 17 Apr 2023 10:00:38 -0700 Subject: [PATCH] [test] Add test for table elems initialized by imported global funcref Fixes: #1640 --- test/core/elem.wast | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/core/elem.wast b/test/core/elem.wast index 5857ae8bd9..4a399ecae6 100644 --- a/test/core/elem.wast +++ b/test/core/elem.wast @@ -675,3 +675,26 @@ (assert_return (invoke $m "get" (i32.const 0)) (ref.null extern)) (assert_return (invoke $m "get" (i32.const 1)) (ref.extern 137)) + +;; Initializing a table with imported funcref global + +(module $module4 + (func (result i32) + i32.const 42 + ) + (global (export "f") funcref (ref.func 0)) +) + +(register "module4" $module4) + +(module + (import "module4" "f" (global funcref)) + (type $out-i32 (func (result i32))) + (table 10 funcref) + (elem (offset (i32.const 0)) funcref (global.get 0)) + (func (export "call_imported_elem") (type $out-i32) + (call_indirect (type $out-i32) (i32.const 0)) + ) +) + +(assert_return (invoke "call_imported_elem") (i32.const 42))