Add raw error message for 2 errors
The errors: `unnamed_map_update_with_default` and `unbound_variable`.
This commit is contained in:
parent
60f3a484e6
commit
0db6d16140
@ -2074,6 +2074,12 @@ get_option(Key, Default) ->
|
||||
when_option(Opt, Do) ->
|
||||
get_option(Opt, false) andalso Do().
|
||||
|
||||
when_option_else(Opt, Do, Else) ->
|
||||
case get_option(Opt, false) of
|
||||
true -> Do();
|
||||
_ -> Else()
|
||||
end.
|
||||
|
||||
%% -- Constraints --
|
||||
|
||||
create_constraints() ->
|
||||
@ -2951,8 +2957,11 @@ mk_error({wrong_type_arguments, X, ArityGiven, ArityReal}) ->
|
||||
),
|
||||
mk_t_err(pos(X), Msg);
|
||||
mk_error({unnamed_map_update_with_default, Upd}) ->
|
||||
Msg = "Invalid map update with default\n",
|
||||
mk_t_err(pos(Upd), Msg);
|
||||
MsgRaw = "Invalid map update with default",
|
||||
Msg = MsgRaw ++ "\n",
|
||||
when_option_else(raw_error_messages,
|
||||
fun() -> mk_t_err(pos(Upd), MsgRaw) end,
|
||||
fun() -> mk_t_err(pos(Upd), Msg) end);
|
||||
mk_error({fundecl_must_have_funtype, _Ann, Id, Type}) ->
|
||||
Msg = io_lib:format("~s at ~s was declared with an invalid type ~s.\n"
|
||||
"Entrypoints and functions must have functional types"
|
||||
@ -2964,12 +2973,17 @@ mk_error({cannot_unify, A, B, When}) ->
|
||||
{Pos, Ctxt} = pp_when(When),
|
||||
mk_t_err(Pos, Msg, Ctxt);
|
||||
mk_error({unbound_variable, Id}) ->
|
||||
MsgRaw = io_lib:format("Unbound variable ~s", [pp(Id)]),
|
||||
Msg = io_lib:format("Unbound variable ~s at ~s\n", [pp(Id), pp_loc(Id)]),
|
||||
case Id of
|
||||
{qid, _, ["Chain", "event"]} ->
|
||||
Cxt = "Did you forget to define the event type?",
|
||||
mk_t_err(pos(Id), Msg, Cxt);
|
||||
_ -> mk_t_err(pos(Id), Msg)
|
||||
when_option_else(raw_error_messages,
|
||||
fun() -> mk_t_err(pos(Id), MsgRaw, Cxt) end,
|
||||
fun() -> mk_t_err(pos(Id), Msg, Cxt) end);
|
||||
_ -> when_option_else(raw_error_messages,
|
||||
fun() -> mk_t_err(pos(Id), MsgRaw) end,
|
||||
fun() -> mk_t_err(pos(Id), Msg) end)
|
||||
end;
|
||||
mk_error({undefined_field, Id}) ->
|
||||
Msg = io_lib:format("Unbound field ~s at ~s\n", [pp(Id), pp_loc(Id)]),
|
||||
|
Loading…
x
Reference in New Issue
Block a user