From 73e5bc7dd4a4e5bc7fcb842a35b91ad587f80fcb Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Mon, 18 Jul 2016 16:34:12 -0700 Subject: WasmFuncDeclaration does not always set `sig` (#93) Prior to this change, the AST parser would always set `sig`, even if the function had no explicit signature (i.e. it used a function type variable instead). This is OK, but it makes the flag confusing. `WASM_FUNC_DECLARATION_FLAG_HAS_SIGNATURE` will be clear and `wasm_decl_has_signature` will return false, but `sig` will be valid. This change makes it so `sig` is only set when there is an explicit signature. The correct way to get the function signature is to call `wasm_decl_get_signature`, which will check whether there is a func type, and if not, will check for an explicit function signature. --- src/wasm-binary-writer-spec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/wasm-binary-writer-spec.c') diff --git a/src/wasm-binary-writer-spec.c b/src/wasm-binary-writer-spec.c index 47b98a04..b5f749a3 100644 --- a/src/wasm-binary-writer-spec.c +++ b/src/wasm-binary-writer-spec.c @@ -309,7 +309,7 @@ static void write_commands(Context* ctx, WasmScript* script) { int func_index = wasm_get_func_index_by_var(last_module, &export->var); assert(func_index >= 0 && (size_t)func_index < last_module->funcs.size); WasmFunc* callee = last_module->funcs.data[func_index]; - WasmType result_type = wasm_get_result_type(callee); + WasmType result_type = wasm_get_result_type(last_module, callee); /* these pointers will be invalidated later, so we can't use them */ export = NULL; callee = NULL; -- cgit v1.2.3