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

Handle abstract code starting with a non-file attribute #2595

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

filmor
Copy link
Contributor

@filmor filmor commented Jul 7, 2021

I'm not really sure how to provoke this, but I had a file that compiled in OTP24 via rebar3 to abstract code that started with a -compile({no_warn_unused_record, [contract]})., so the first entry of the AbstractCode list was {attribute,0,compile,{nowarn_unused_record,[[contract]]}}. This PR filters the AbstractCode list for -file attributes before matching. I can make this more efficient if you want.

@filmor
Copy link
Contributor Author

filmor commented Jul 12, 2021

The failing shell test is related to the currently broken rebar_mix, I think.

@ferd
Copy link
Collaborator

ferd commented Jul 12, 2021

Yeah the code itself ought to be safe. I do similar stripping in the EPP-adjacent code, though I'm just surprised someone did manage to add attributes before -file, since the -module attribute directly translates to that and is supposed to be first.

Anyway, the code doesn't harm anything else (might slow down processing a bit on super large modules with lots of constructs), and if there's a regression we can probably replace it with a dropwhile + hd call

@ferd ferd merged commit 5a78a08 into erlang:master Jul 12, 2021
@filmor filmor deleted the skip-non-file-attrs branch July 12, 2021 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants