diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index f866c1e..8a59964 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -1156,8 +1156,6 @@ infer_expr(Env, {typed, As, Body, Type}) -> {typed, _, NewBody, NewType} = check_expr(Env, Body, Type1), {typed, As, NewBody, NewType}; infer_expr(Env, {app, Ann, Fun, Args0}) -> - %% TODO: fix parser to give proper annotation for normal applications! - FunAnn = aeso_syntax:get_ann(Fun), NamedArgs = [ Arg || Arg = {named_arg, _, _, _} <- Args0 ], Args = Args0 -- NamedArgs, case aeso_syntax:get_ann(format, Ann) of @@ -1166,15 +1164,15 @@ infer_expr(Env, {app, Ann, Fun, Args0}) -> prefix -> infer_op(Env, Ann, Fun, Args, fun infer_prefix/1); _ -> - NamedArgsVar = fresh_uvar(FunAnn), + NamedArgsVar = fresh_uvar(Ann), NamedArgs1 = [ infer_named_arg(Env, NamedArgsVar, Arg) || Arg <- NamedArgs ], %% TODO: named args constraints NewFun={typed, _, _, FunType} = infer_expr(Env, Fun), NewArgs = [infer_expr(Env, A) || A <- Args], ArgTypes = [T || {typed, _, _, T} <- NewArgs], - ResultType = fresh_uvar(FunAnn), + ResultType = fresh_uvar(Ann), unify(Env, FunType, {fun_t, [], NamedArgsVar, ArgTypes, ResultType}, {infer_app, Fun, Args, FunType, ArgTypes}), - {typed, FunAnn, {app, Ann, NewFun, NamedArgs1 ++ NewArgs}, dereference(ResultType)} + {typed, Ann, {app, Ann, NewFun, NamedArgs1 ++ NewArgs}, dereference(ResultType)} end; infer_expr(Env, {'if', Attrs, Cond, Then, Else}) -> NewCond = check_expr(Env, Cond, {id, Attrs, "bool"}), diff --git a/src/aeso_parser.erl b/src/aeso_parser.erl index 0156db0..d02ee35 100644 --- a/src/aeso_parser.erl +++ b/src/aeso_parser.erl @@ -312,7 +312,7 @@ map_key(Key, {ok, {_, Val}}) -> {map_key, Key, Val}. elim(E, []) -> E; elim(E, [{proj, Ann, P} | Es]) -> elim({proj, Ann, E, P}, Es); -elim(E, [{app, Ann, Args} | Es]) -> elim({app, Ann, E, Args}, Es); +elim(E, [{app, _Ann, Args} | Es]) -> elim({app, aeso_syntax:get_ann(E), E, Args}, Es); elim(E, [{rec_upd, Ann, Flds} | Es]) -> elim(record_update(Ann, E, Flds), Es); elim(E, [{map_get, Ann, Key} | Es]) -> elim({map_get, Ann, E, Key}, Es); elim(E, [{map_get, Ann, Key, Val} | Es]) -> elim({map_get, Ann, E, Key, Val}, Es). diff --git a/test/aeso_compiler_tests.erl b/test/aeso_compiler_tests.erl index 802d129..5c4bed8 100644 --- a/test/aeso_compiler_tests.erl +++ b/test/aeso_compiler_tests.erl @@ -301,7 +301,14 @@ failing_contracts() -> <>, <>]) + "Let binding at line 58, column 5 must be followed by an expression">>, + <>]) , ?TYPE_ERROR(init_type_error, [<