Revert "Add raw error message for 2 errors"

This reverts commit 0db6d16140d52e29cd8a12d8719ee57ca874d5f5.
This commit is contained in:
Gaith Hallak 2021-12-17 13:38:02 +02:00
parent 0db6d16140
commit d8d82737d4

View File

@ -2074,12 +2074,6 @@ get_option(Key, Default) ->
when_option(Opt, Do) -> when_option(Opt, Do) ->
get_option(Opt, false) andalso Do(). get_option(Opt, false) andalso Do().
when_option_else(Opt, Do, Else) ->
case get_option(Opt, false) of
true -> Do();
_ -> Else()
end.
%% -- Constraints -- %% -- Constraints --
create_constraints() -> create_constraints() ->
@ -2957,11 +2951,8 @@ mk_error({wrong_type_arguments, X, ArityGiven, ArityReal}) ->
), ),
mk_t_err(pos(X), Msg); mk_t_err(pos(X), Msg);
mk_error({unnamed_map_update_with_default, Upd}) -> mk_error({unnamed_map_update_with_default, Upd}) ->
MsgRaw = "Invalid map update with default", Msg = "Invalid map update with default\n",
Msg = MsgRaw ++ "\n", mk_t_err(pos(Upd), Msg);
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}) -> mk_error({fundecl_must_have_funtype, _Ann, Id, Type}) ->
Msg = io_lib:format("~s at ~s was declared with an invalid type ~s.\n" Msg = io_lib:format("~s at ~s was declared with an invalid type ~s.\n"
"Entrypoints and functions must have functional types" "Entrypoints and functions must have functional types"
@ -2973,17 +2964,12 @@ mk_error({cannot_unify, A, B, When}) ->
{Pos, Ctxt} = pp_when(When), {Pos, Ctxt} = pp_when(When),
mk_t_err(Pos, Msg, Ctxt); mk_t_err(Pos, Msg, Ctxt);
mk_error({unbound_variable, Id}) -> 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)]), Msg = io_lib:format("Unbound variable ~s at ~s\n", [pp(Id), pp_loc(Id)]),
case Id of case Id of
{qid, _, ["Chain", "event"]} -> {qid, _, ["Chain", "event"]} ->
Cxt = "Did you forget to define the event type?", Cxt = "Did you forget to define the event type?",
when_option_else(raw_error_messages, mk_t_err(pos(Id), Msg, Cxt);
fun() -> mk_t_err(pos(Id), MsgRaw, Cxt) end, _ -> mk_t_err(pos(Id), Msg)
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; end;
mk_error({undefined_field, Id}) -> mk_error({undefined_field, Id}) ->
Msg = io_lib:format("Unbound field ~s at ~s\n", [pp(Id), pp_loc(Id)]), Msg = io_lib:format("Unbound field ~s at ~s\n", [pp(Id), pp_loc(Id)]),