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

Fix parsing trailing comments in modules #1178

Merged
merged 1 commit into from
Jan 21, 2022

Conversation

gomoripeti
Copy link
Contributor

erlfmt_parser returns a raw_string form for comments which are after the last
form in the file and not followed by any more form. It was not expected by
els_parser that a raw_string can contain no tokens (just comments and
whitespace). A file with no code just whitespace has the same result.

Fixes #1171

erlfmt_parser returns a `raw_string` form for comments which are after the last
form in the file and not followed by any more form. It was not expected by
els_parser that a raw_string can contain no tokens (just comments and
whitespace). A file with no code just whitespace has the same result.

Fixes erlang-ls#1171
Comment on lines +114 to +117
%% `els_parser:parse' actually catches the exception and only prints a warning
%% log. In order to make sure there is no crash, we need to call an internal
%% debug function that would really crash and make the test case fail
error = els_parser:parse_incomplete_text(Text1, {1, 1}),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a better way to make sure no warning log is emitted in ct tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I'm following 100%, but an option could be to (eventually isolate and) mock with passthrough the function generating the warning and check from CT if the function was called via meck_history or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

@robertoaloi
Copy link
Member

I will merge this now, given it causes crashes. Feel free to provide the CT change as a follow up. Thanks for fixing this!

@robertoaloi robertoaloi merged commit e648a96 into erlang-ls:main Jan 21, 2022
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.

els_parser:parse_form/1 fails on lists:last
2 participants