From 062309e578fc852bc4e37c26fc53e1dd19ae5407 Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Fri, 30 Aug 2019 14:22:31 +0200 Subject: [PATCH] Type variables mentioned in local functions should not be flexible (cc #112) --- src/aeso_ast_infer_types.erl | 2 +- test/contracts/local_poly_fail.aes | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/contracts/local_poly_fail.aes diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 5a07a9f..5e58a45 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -1327,7 +1327,7 @@ infer_block(Env, _, [E], BlockType) -> [check_expr(Env, E, BlockType)]; infer_block(Env, Attrs, [Def={letfun, Ann, _, _, _, _}|Rest], BlockType) -> {{Name, TypeSig}, LetFun} = infer_letfun(Env, Def), - FunT = freshen_type(Ann, typesig_to_fun_t(TypeSig)), + FunT = typesig_to_fun_t(TypeSig), NewE = bind_var({id, Ann, Name}, FunT, Env), [LetFun|infer_block(NewE, Attrs, Rest, BlockType)]; infer_block(Env, _, [{letval, Attrs, Pattern, Type, E}|Rest], BlockType) -> diff --git a/test/contracts/local_poly_fail.aes b/test/contracts/local_poly_fail.aes new file mode 100644 index 0000000..189ab23 --- /dev/null +++ b/test/contracts/local_poly_fail.aes @@ -0,0 +1,7 @@ + +contract Fail = + + entrypoint tttt() : bool * int = + let f(x : 'a) : 'a = x + (f(true), f(1)) +