From d844c4d276b78fd5100a026ac612e26f3f085617 Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Thu, 12 Dec 2019 08:50:17 +0100 Subject: [PATCH] Fix missing type annotation in list comprehension body --- src/aeso_ast_infer_types.erl | 2 +- test/aeso_compiler_tests.erl | 1 + test/contracts/lc_record_bug.aes | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/contracts/lc_record_bug.aes diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index fcca92f..5afe2e3 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -1138,7 +1138,7 @@ infer_expr(Env, {list, As, Elems}) -> NewElems = [check_expr(Env, X, ElemType) || X <- Elems], {typed, As, {list, As, NewElems}, {app_t, As, {id, As, "list"}, [ElemType]}}; infer_expr(Env, {list_comp, As, Yield, []}) -> - {typed, _, TypedYield, Type} = infer_expr(Env, Yield), + {typed, _, _, Type} = TypedYield = infer_expr(Env, Yield), {typed, As, {list_comp, As, TypedYield, []}, {app_t, As, {id, As, "list"}, [Type]}}; infer_expr(Env, {list_comp, As, Yield, [{comprehension_bind, Arg, BExpr}|Rest]}) -> BindVarType = fresh_uvar(As), diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index b4d400e..3ddca8c 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -138,6 +138,7 @@ compilable_contracts() -> "test", "builtin_bug", "builtin_map_get_bug", + "lc_record_bug", "nodeadcode", "deadcode", "variant_types", diff --git a/test/contracts/lc_record_bug.aes b/test/contracts/lc_record_bug.aes new file mode 100644 index 0000000..dcce24d --- /dev/null +++ b/test/contracts/lc_record_bug.aes @@ -0,0 +1,4 @@ +contract Foo = + record r = {x : int} + // Crashed in the backend due to missing type annotation on the lc body. + entrypoint lc(xs) = [ {x = x} | x <- xs ]