Skip to content
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

Incorrect format when macro is used while building a binary #81

Closed
tgrk opened this issue Feb 25, 2020 · 5 comments · Fixed by #258
Closed

Incorrect format when macro is used while building a binary #81

tgrk opened this issue Feb 25, 2020 · 5 comments · Fixed by #258
Labels
bug Something isn't working

Comments

@tgrk
Copy link

tgrk commented Feb 25, 2020

I was able to successfully reformat quite a big codebase and have to say only one thing - What a great job!

The only issue that I found is that I had multiple syntax issues with this pattern:

<<?i2b(IntegerValue)/binary, " foobar">>

instead of correct one:

<<(?i2b(IntegerValue))/binary, " foobar">>

?i2b/1 macro is just a conversion from integer to binary using BIF function without any wrapper.

Thank you again for a great tool! 🙏

@elbrujohalcon elbrujohalcon added the bug Something isn't working label Feb 26, 2020
@elbrujohalcon
Copy link
Collaborator

Probably a duplicate of #74 . @tgrk please confirm.

@hommeabeil
Copy link

I can confirm there is an error in the binary, consider those lines,

-define(CHUNK_SIZE, 65535 - 1).

chunkify(<<Binary:(?CHUNK_SIZE)/binary, Rest/binary>>) ->
    some code ...

Its get reformat as, which is invalide:

chunkify(<<Binary:?CHUNK_SIZE/binary, Rest/binary>>) ->

@elbrujohalcon
Copy link
Collaborator

Right, so… when fixing #74, we'll probably fix this one, too.

@hommeabeil
Copy link

For my case it is.

@elbrujohalcon elbrujohalcon added this to the 0.3.0 milestone Apr 9, 2020
@elbrujohalcon
Copy link
Collaborator

elbrujohalcon commented Apr 28, 2020

This is not the same issue as #74, which deals with removing parentheses from within macro definitions.
This one deals with removing parentheses when macros are treated as variables in expressions. This one will be really hard to solve because by the time we get to the point of writing the code we have no information about the presence of parentheses on the original code.

@elbrujohalcon elbrujohalcon modified the milestones: 0.3.0, After Improving ktn_code May 6, 2020
@elbrujohalcon elbrujohalcon modified the milestones: After Improving ktn_code, Eventually 🙄 Nov 18, 2020
@elbrujohalcon elbrujohalcon modified the milestones: Eventually 🙄, 0.9.0 Nov 26, 2020
@elbrujohalcon elbrujohalcon modified the milestones: 0.9.0, Eventually 🙄 Feb 9, 2021
vkatsuba added a commit to vkatsuba/rebar3_format that referenced this issue May 6, 2021
vkatsuba added a commit to vkatsuba/rebar3_format that referenced this issue May 6, 2021
vkatsuba added a commit to vkatsuba/rebar3_format that referenced this issue May 7, 2021
elbrujohalcon added a commit that referenced this issue May 7, 2021
elbrujohalcon added a commit that referenced this issue May 7, 2021
elbrujohalcon added a commit that referenced this issue May 7, 2021
elbrujohalcon pushed a commit that referenced this issue May 10, 2021
* [#81] Alternative approach to fix #81

* [#81] Refactor

* [#81] Some improvements, but it's still removing comments

* [#81] Improve the example by starting from stuff without parentheses

* [#81] Hacky improvement for size qualifiers

* [#81] Handle comments, too
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants