Skip to content

Commit 7fe1d95

Browse files
authored
Merge pull request erlang#11141 from garazdawi/lukas/stdlib/fix-erl_expand-native-record
stdlib: Fix update of anon records with a tuple record
2 parents 2ff3eaa + b22a162 commit 7fe1d95

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

lib/stdlib/src/erl_expand_records.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ expr({record,_A,Arg0,{_,_}=Id,Updates}, St0) ->
457457
expr({record,_A,Arg0,[]=Id,Updates}, St0) ->
458458
Anno = erl_parse:first_anno(Arg0),
459459
{Arg1,St1} = expr(Arg0, St0),
460-
{Es1, St1} = expr_list(Updates, St0),
461-
{{record,Anno,Arg1,Id,Es1},St1};
460+
{Es1, St2} = expr_list(Updates, St1),
461+
{{record,Anno,Arg1,Id,Es1},St2};
462462
expr({record,Anno0,Arg0,Name,Updates}, St0) when is_atom(Name) ->
463463
case St0#exprec.rec_mod of
464464
#{Name := {local, _}} ->

lib/stdlib/test/erl_expand_records_SUITE.erl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
init/1, pattern/1, strict/1, update/1,
4343
otp_5915/1, otp_7931/1, otp_5990/1,
4444
otp_7078/1, maps/1, zlc/1,
45-
side_effects/1]).
45+
side_effects/1,
46+
update_anon_native_record/1]).
4647

4748
init_per_testcase(_Case, Config) ->
4849
Config.
@@ -57,7 +58,8 @@ suite() ->
5758
all() ->
5859
[attributes, expr, guard, init,
5960
pattern, strict, update, maps,
60-
side_effects, zlc, {group, tickets}].
61+
side_effects, zlc, {group, tickets},
62+
update_anon_native_record].
6163

6264
groups() ->
6365
[{tickets, [],
@@ -769,6 +771,23 @@ otp_7078(Config) when is_list(Config) ->
769771
run(Config, Ts, [strict_record_tests]),
770772
ok.
771773

774+
update_anon_native_record(Config) when is_list(Config) ->
775+
776+
Ts = [
777+
~"""
778+
-record #nr{x = 0, y = 0}.
779+
-record(tup, {a,b}).
780+
781+
t() ->
782+
R0 = #nr{},
783+
T0 = #tup{},
784+
R0#_{x = (T0#tup.a)},
785+
ok.
786+
"""],
787+
run(Config, Ts),
788+
ok.
789+
790+
772791
id(I) -> I.
773792

774793
-record(side_effects, {a,b,c}).

0 commit comments

Comments
 (0)