// Copyright 2019 the V8 project authors. All rights reserved.// Use of this source code is governed by a BSD-style license that can be// found in the LICENSE file.// Flags: --no-experimental-wasm-bigintload('test/mjsunit/wasm/wasm-module-builder.js');// Generate a re-exported function that wraps a JavaScript callable, but with a// function signature that is incompatible (i.e. i64 return type) with JS.varfun1=(functionGenerateFun1(){letbuilder=newWasmModuleBuilder();functionfun(){return0}letfun_index=builder.addImport("m","fun",kSig_l_v)builder.addExport("fun",fun_index);letinstance=builder.instantiate({m:{fun:fun}});returninstance.exports.fun;})();// Generate an exported function that calls the above re-export from another// module, still with a function signature that is incompatible with JS.varfun2=(functionGenerateFun2(){letbuilder=newWasmModuleBuilder();letfun_index=builder.addImport("m","fun",kSig_l_v)builder.addFunction('main',kSig_v_v).addBody([kExprCallFunction,fun_index,kExprDrop]).exportFunc();letinstance=builder.instantiate({m:{fun:fun1}});returninstance.exports.main;})();// Both exported functions should throw, no matter how often they get wrapped.assertThrows(fun1,TypeError,/wasm function signature contains illegal type/);assertThrows(fun2,TypeError,/wasm function signature contains illegal type/);