-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
convert erl_anno:anno() to integer() at transform #4
Conversation
@@ -111,7 +111,7 @@ transform_call(logi, Severity0, {_, _, _, Args} = Call, Loc = #location{line_or_ | |||
[Logger, {string, _, _} = Fmt] -> | |||
Opts = {cons, LineOrAnno, {tuple, LineOrAnno, [{atom, LineOrAnno, logger}, Logger]}, {nil, LineOrAnno}}, | |||
logi_call_expr(Severity, Fmt, {nil, LineOrAnno}, Opts, Loc); | |||
[Logger, {string, _, _} = Fmt, {nil, LineOrAnno} = Data] -> | |||
[Logger, {string, _, _} = Fmt, {nil, _} = Data] -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When anno contains column, LineOrAnno that is bound at #location{line_or_anno = LineOrAnno}
will not match here.
@@ -136,7 +136,7 @@ logi_location_expr(Loc = #location{line_or_anno = LineOrAnno}) -> | |||
{atom, LineOrAnno, Loc#location.application}, | |||
{atom, LineOrAnno, Loc#location.module}, | |||
{atom, LineOrAnno, Loc#location.function}, | |||
{integer, LineOrAnno, LineOrAnno} | |||
{integer, LineOrAnno, logi_transform_utils:line_or_anno_to_line(LineOrAnno)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When anno contains column, this made malformed abstract format values like {integer, {10, 12}, {10, 12}}
wherer the third element must be an integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Thanks again 🙏
The implementation of treating erl_anno:anno() in #3 has the following problems. (I'm very sorry.)
logi_location:unsafe_new/5
acceptsline_or_anno() :: line() | erl_anno:anno()
whereerl_anno:anno()
is opaque{10, 12}
are placed after transform, dialyzer raises an error that says no compatible typeslogi_transform:logi_location_expr/1
makes malformed abstract format values like{integer, {10, 12}, {10, 12}}
This PR addresses these problems by converting
erl_anno:anno()
tointeger()
in the logi_transform process.In addition, this fixes unintended pettern match in v0.0.12-compatible transform when Data is
[]
.