From 11d998b7399575a83983241dbe8b3126ae983a99 Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Sat, 14 Sep 2019 12:07:48 +0200 Subject: [PATCH] Set source location for function applications --- src/aeso_ast_infer_types.erl | 8 +++----- src/aeso_parser.erl | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 87066ec..f831e6c 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -1155,8 +1155,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 @@ -1165,15 +1163,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).