|
Original patch from YAMASHINA Hio posted to erlang-patches@
on Tue Jun 12 11:27:53 CEST 2007:
http://www.erlang.org/pipermail/erlang-patches/2007-June/000182.html
http://fleur.hio.jp/pub/erlang/record2.patch
Only had to do minor changes to port the patch to the
current R14A development tree.
Also added compiler/record_SUITE:nested_access/2 to test
nested record access with or without parentheses.
With this change the following will work.
-record(nrec0, {name = <<"nested0">>}).
-record(nrec1, {name = <<"nested1">>, nrec0=#nrec0{}}).
-record(nrec2, {name = <<"nested2">>, nrec1=#nrec1{}}).
nested_access() ->
N0 = #nrec0{},
N1 = #nrec1{},
N2 = #nrec2{},
<<"nested0">> = N0#nrec0.name,
<<"nested1">> = N1#nrec1.name,
<<"nested2">> = N2#nrec2.name,
<<"nested0">> = N1#nrec1.nrec0#nrec0.name,
<<"nested0">> = N2#nrec2.nrec1#nrec1.nrec0#nrec0.name,
<<"nested1">> = N2#nrec2.nrec1#nrec1.name,
<<"nested0">> = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0.name,
N1a = N2#nrec2.nrec1#nrec1{name = <<"nested1a">>},
<<"nested1a">> = N1a#nrec1.name,
N2a = N2#nrec2.nrec1#nrec1.nrec0#nrec0{name = <<"nested0a">>},
N2b = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0{name = <<"nested0a">>},
<<"nested0a">> = N2a#nrec0.name,
N2a = N2b,
ok.
Signed-off-by: Tuncer Ayaz <[email protected]>
|