Handle annotations and locations better#3
Handle annotations and locations better#3uabboli wants to merge 2 commits intojkrukoff:masterfrom uabboli:annotations
Conversation
This PR is one of several affecting repositories on Github. It
aims at fixing bad use of annotations (see erl_anno(3)). The
following remarks are common to all PR:s.
Typically the second element of abstract code tuples is assumed
to be an integer, which is no longer always true. For instance,
the parse transform implementing QLC tables (see qlc(3)) returns
code where some annotations are marked as `generated'. Such an
annotation is a list, not an integer (it used to be a negative
integer).
As of Erlang/OTP 24.0, the location can be a tuple {Line, Column},
which is another reason to handle annotations properly.
Just to clearify that Pos is not necessarily an integer line number.
|
I'm not sure if I'm looking at a human or computer generated PR here. I can understand wanting to rename the internal variable from Line to Pos, especially given that it's meaning is changing. I believe the only thing I'm doing with the value from erl_syntax:get_pos is passing it into merl (and set_pos), however. A glance at the docs show merl already expecting an annotation value. This makes me suspicious that the transformation added here to extract a line number from the annotation is actually losing information, when instead the annotation should just be passed along as is. As it's been quite a while since I last looked at the erl_syntax/merl documentation it's quite possible I'm missing something. Can you explain why this PR shouldn't just be a global rename from |
Could you explain why you think so? It's an honest question; I'm
According to merl(3), the type of the first argument of qquote() is As I wrote in the commit message, locations will be {Line, Column} by Since the representation of erl_anno:anno() and erl_anno:location() is To sum it up: you don't have to merge this PR; the code will not stop And I see now that I could (should) have used erl_anno:get_location() |
See comment in first commit.