Remove duplicated record definition

This commit is contained in:
Gaith Hallak 2023-04-21 21:13:29 +03:00
parent 1f0726fad7
commit 296b2a4bb0
3 changed files with 14 additions and 17 deletions

View File

@ -18,7 +18,11 @@
, unfold_types_in_type/3
, switch_scope/2
, lookup_env1/4
, get_env_namespace/1 %% TODO: Newly added
%% TODO: Newly added
, get_env_namespace/1
, get_named_argument_constraint_name/1
, get_named_argument_constraint_args/1
, get_named_argument_constraint_type/1
]).
-include("aeso_utils.hrl").
@ -185,6 +189,9 @@ pp_loc(A) -> aeso_tc_pp:pp_loc(A).
%% -- New functions ----------------------------------------------------------
get_env_namespace(#env{namespace = Namespace}) -> Namespace.
get_named_argument_constraint_name(#named_argument_constraint{name = Name}) -> Name.
get_named_argument_constraint_args(#named_argument_constraint{args = Args}) -> Args.
get_named_argument_constraint_type(#named_argument_constraint{type = Type}) -> Type.
%% -- Environment manipulation -----------------------------------------------

View File

@ -8,13 +8,6 @@
, destroy_and_report_type_errors/1
]).
%% -- Duplicated types -------------------------------------------------------
-record(named_argument_constraint,
{args :: aeso_ast_infer_types:named_args_t(), %% TODO: Unexported type
name :: aeso_syntax:id(),
type :: aeso_ast_infer_types:utype()}). %% TODO: Unexported type
%% -- Moved functions --------------------------------------------------------
name(A) -> aeso_tc_name_manip:name(A).
@ -217,7 +210,9 @@ mk_error({bad_named_argument, Args, Name}) ->
[ io_lib:format("\n - `~s`", [pp_typed("", Arg, Type)])
|| {named_arg_t, _, Arg, Type, _} <- Args ]]),
mk_t_err(pos(Name), Msg);
mk_error({unsolved_named_argument_constraint, #named_argument_constraint{name = Name, type = Type}}) ->
mk_error({unsolved_named_argument_constraint, C}) ->
Name = aeso_ast_infer_types:get_named_argument_constraint_name(C),
Type = aeso_ast_infer_types:get_named_argument_constraint_type(C),
Msg = io_lib:format("Named argument ~s supplied to function with unknown named arguments.",
[pp_typed("", Name, Type)]),
mk_t_err(pos(Name), Msg);

View File

@ -16,11 +16,6 @@
| {var_args, aeso_syntax:ann(), aeso_syntax:expr()}
| {proj, aeso_syntax:ann(), aeso_syntax:expr(), aeso_syntax:id()}.
-record(named_argument_constraint,
{args :: aeso_ast_infer_types:named_args_t(), %% TODO: Unexported type
name :: aeso_syntax:id(),
type :: aeso_ast_infer_types:utype()}). %% TODO: Unexported type
%% -- Moved functions --------------------------------------------------------
pos(A) -> aeso_tc_ann_manip:pos(A).
@ -137,10 +132,10 @@ pp_when({list_comp, BindExpr, Inferred0, Expected0}) ->
io_lib:format("when checking rvalue of list comprehension binding `~s` against type `~s`",
[pp_typed("", BindExpr, Inferred), pp_type(Expected)])};
pp_when({check_named_arg_constraint, C}) ->
{id, _, Name} = Arg = C#named_argument_constraint.name,
[Type | _] = [ Type || {named_arg_t, _, {id, _, Name1}, Type, _} <- C#named_argument_constraint.args, Name1 == Name ],
{id, _, Name} = Arg = aeso_ast_infer_types:get_named_argument_constraint_name(C),
[Type | _] = [ Type || {named_arg_t, _, {id, _, Name1}, Type, _} <- aeso_ast_infer_types:get_named_argument_constraint_args(C), Name1 == Name ],
Err = io_lib:format("when checking named argument `~s` against inferred type `~s`",
[pp_typed("", Arg, Type), pp_type(C#named_argument_constraint.type)]),
[pp_typed("", Arg, Type), pp_type(aeso_ast_infer_types:get_named_argument_constraint_type(C))]),
{pos(Arg), Err};
pp_when({checking_init_args, Ann, Con0, ArgTypes0}) ->
Con = aeso_type_utils:instantiate(Con0),