Merge pull request #153 from aeternity/src-loc-for-fun-app
Fix bug with missing source location for function applications
This commit is contained in:
commit
662e5e70ef
@ -1156,8 +1156,6 @@ infer_expr(Env, {typed, As, Body, Type}) ->
|
|||||||
{typed, _, NewBody, NewType} = check_expr(Env, Body, Type1),
|
{typed, _, NewBody, NewType} = check_expr(Env, Body, Type1),
|
||||||
{typed, As, NewBody, NewType};
|
{typed, As, NewBody, NewType};
|
||||||
infer_expr(Env, {app, Ann, Fun, Args0}) ->
|
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 ],
|
NamedArgs = [ Arg || Arg = {named_arg, _, _, _} <- Args0 ],
|
||||||
Args = Args0 -- NamedArgs,
|
Args = Args0 -- NamedArgs,
|
||||||
case aeso_syntax:get_ann(format, Ann) of
|
case aeso_syntax:get_ann(format, Ann) of
|
||||||
@ -1166,15 +1164,15 @@ infer_expr(Env, {app, Ann, Fun, Args0}) ->
|
|||||||
prefix ->
|
prefix ->
|
||||||
infer_op(Env, Ann, Fun, Args, fun infer_prefix/1);
|
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 ],
|
NamedArgs1 = [ infer_named_arg(Env, NamedArgsVar, Arg) || Arg <- NamedArgs ],
|
||||||
%% TODO: named args constraints
|
%% TODO: named args constraints
|
||||||
NewFun={typed, _, _, FunType} = infer_expr(Env, Fun),
|
NewFun={typed, _, _, FunType} = infer_expr(Env, Fun),
|
||||||
NewArgs = [infer_expr(Env, A) || A <- Args],
|
NewArgs = [infer_expr(Env, A) || A <- Args],
|
||||||
ArgTypes = [T || {typed, _, _, T} <- NewArgs],
|
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}),
|
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;
|
end;
|
||||||
infer_expr(Env, {'if', Attrs, Cond, Then, Else}) ->
|
infer_expr(Env, {'if', Attrs, Cond, Then, Else}) ->
|
||||||
NewCond = check_expr(Env, Cond, {id, Attrs, "bool"}),
|
NewCond = check_expr(Env, Cond, {id, Attrs, "bool"}),
|
||||||
|
@ -312,7 +312,7 @@ map_key(Key, {ok, {_, Val}}) -> {map_key, Key, Val}.
|
|||||||
|
|
||||||
elim(E, []) -> E;
|
elim(E, []) -> E;
|
||||||
elim(E, [{proj, Ann, P} | Es]) -> elim({proj, Ann, E, P}, Es);
|
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, [{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} | Es]) -> elim({map_get, Ann, E, Key}, Es);
|
||||||
elim(E, [{map_get, Ann, Key, Val} | Es]) -> elim({map_get, Ann, E, Key, Val}, Es).
|
elim(E, [{map_get, Ann, Key, Val} | Es]) -> elim({map_get, Ann, E, Key, Val}, Es).
|
||||||
|
@ -301,7 +301,14 @@ failing_contracts() ->
|
|||||||
<<?Pos(54, 5)
|
<<?Pos(54, 5)
|
||||||
"Let binding at line 54, column 5 must be followed by an expression">>,
|
"Let binding at line 54, column 5 must be followed by an expression">>,
|
||||||
<<?Pos(58, 5)
|
<<?Pos(58, 5)
|
||||||
"Let binding at line 58, column 5 must be followed by an expression">>])
|
"Let binding at line 58, column 5 must be followed by an expression">>,
|
||||||
|
<<?Pos(63, 5)
|
||||||
|
"Cannot unify int\n"
|
||||||
|
" and bool\n"
|
||||||
|
"when checking the type of the expression at line 63, column 5\n"
|
||||||
|
" id(n) : int\n"
|
||||||
|
"against the expected type\n"
|
||||||
|
" bool">>])
|
||||||
, ?TYPE_ERROR(init_type_error,
|
, ?TYPE_ERROR(init_type_error,
|
||||||
[<<?Pos(7, 3)
|
[<<?Pos(7, 3)
|
||||||
"Cannot unify string\n"
|
"Cannot unify string\n"
|
||||||
|
@ -57,3 +57,8 @@ contract Test =
|
|||||||
let f() = 0
|
let f() = 0
|
||||||
let g() = f()
|
let g() = f()
|
||||||
|
|
||||||
|
function id(x : 'a) : 'a = x
|
||||||
|
|
||||||
|
entrypoint wrong_return(n : int) : bool =
|
||||||
|
id(n)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user