Skip to content

Commit

Permalink
Warning and shadowing (#293)
Browse files Browse the repository at this point in the history
* Fix unused variables

* Fix shadowed variables
  • Loading branch information
Francois Brodeur authored Nov 2, 2020
1 parent 766ba27 commit 6e75cc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/typechecker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ type_check_fields(Env, TypedRecFields, [{record_field, _, {atom, _, _} = FieldWi
{VB1, Cs1} = type_check_expr_in(Env, FieldTy, Expr),
{VB2, Cs2} = type_check_fields(Env, TypedRecFields, Fields, UnAssignedFields),
{union_var_binds(VB1, VB2, Env#env.tenv), constraints:combine(Cs1,Cs2)};
type_check_fields(Env, TypedRecFields, [{record_field, _, {var, _, '_'}, Expr} | Fields]
type_check_fields(Env, TypedRecFields, [{record_field, _, {var, _, '_'}, Expr} | _Fields]
,UnAssignedFields) ->
{VB1, Cs1} = type_check_fields(Env, TypedRecFields
,[ {record_field, erl_anno:new(0)
Expand Down Expand Up @@ -2214,7 +2214,7 @@ do_type_check_expr_in(Env, ResTy, {record, Anno, Exp, Name, Fields} = Record) ->
end
,Fields)
),
RecordTy = type_record(Name, [type_field_type(Name, Type) || ?typed_record_field(Name, Type) <- Rec]),
RecordTy = type_record(Name, [type_field_type(FieldName, Type) || ?typed_record_field(FieldName, Type) <- Rec]),
{VarBinds, Cs2} = type_check_expr_in(Env, RecordTy, Exp),
{union_var_binds([VarBinds|VarBindsList], Env#env.tenv)
,constraints:combine([Cs1, Cs2|Css])};
Expand Down Expand Up @@ -3332,7 +3332,7 @@ refine(OrigTy, Ty, TEnv) ->

get_record_fields_types(Name, Anno, TEnv) ->
RecordFields = get_maybe_remote_record_fields(Name, Anno, TEnv),
[type_field_type(Name, Type) || ?typed_record_field(Name, Type) <- RecordFields].
[type_field_type(FieldName, Type) || ?typed_record_field(FieldName, Type) <- RecordFields].

expand_record(Name, Anno, TEnv) ->
type_record(Name, get_record_fields_types(Name, Anno, TEnv)).
Expand Down
2 changes: 1 addition & 1 deletion src/typelib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ remove_pos({type, _, Assoc, Tys}) when Assoc == map_field_exact;
remove_pos({remote_type, _, [Mod, Name, Params]}) ->
Params1 = lists:map(fun remove_pos/1, Params),
{remote_type, erl_anno:new(0), [Mod, Name, Params1]};
remove_pos({ann_type, _, [Var, Type]}) ->
remove_pos({ann_type, _, [_Var, Type]}) ->
%% Also remove annotated types one the form Name :: Type
remove_pos(Type);
remove_pos({op, _, Op, Type}) ->
Expand Down

0 comments on commit 6e75cc3

Please sign in to comment.