erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.42k stars 2.96k forks source link

erl_syntax:set_pos/2 or erl_syntax:revert/1 is not works as expected #4668

Open slepher opened 3 years ago

slepher commented 3 years ago

Describe the bug erl_syntax:set_pos/2 or erl_syntax:revert/1 is not works as expected

Node = {atom, 20, a}.
Node1 = erl_syntax:revert(erl_syntax:set_pos(Node, 10)).
?assertEqual({atom, 10, a}, Node).

assertEqual above fails.

Reason erl_syntax use a wrapper to wrap erl_parse tree and erl_syntax:set_pos/2 only changes #wrapper.attr in wrapper record while use erl_syntax:revert/1 #wrapper.attr is dropped, original pos in erl_parse tree is not changed

Affected versions OTP 23 and higher

MarkoMin commented 2 months ago

I believe that this is solved by https://github.com/erlang/otp/pull/7398

In OTP27, the assertion above succeeds.