diff --git a/src/hz.erl b/src/hz.erl index 1fec2c3..27a22cf 100644 --- a/src/hz.erl +++ b/src/hz.erl @@ -1453,7 +1453,7 @@ convert_function_spec(#{name := NameBin, arguments := Args, returns := Result}) convert_arg(#{name := NameBin, type := TypeDef}) -> Name = binary_to_list(NameBin), - {ok, Type} = opaque_type([], TypeDef), + Type = opaque_type([], TypeDef), {Name, Type}. convert_namespace_typedefs(#{namespace := NS}) -> @@ -1561,7 +1561,7 @@ opaque_type_name(Name) -> binary_to_list(Name). annotate_function_specs([], _Types, Specs) -> Specs; annotate_function_specs([{Name, ArgsOpaque, ResultOpaque} | Rest], Types, Specs) -> - {ok, Args} = annotate_types(ArgsOpaque, Types, []), + {ok, Args} = annotate_bindings(ArgsOpaque, Types, []), {ok, Result} = annotate_type(ResultOpaque, Types), NewSpecs = maps:put(Name, {Args, Result}, Specs), annotate_function_specs(Rest, Types, NewSpecs). @@ -2358,3 +2358,14 @@ state_coerce_test() -> {ok, {[], Output}} = aaci_lookup_spec(AACI, "init"), try_coerce(Output, 0, 0). +param_test() -> + Contract = " + contract C = + type state = int + entrypoint init(x): state = x + ", + {ok, AACI} = aaci_from_string(Contract), + {ok, {[{"x", Input}], Output}} = aaci_lookup_spec(AACI, "init"), + try_coerce(Input, 0, 0), + try_coerce(Output, 0, 0). +