-
Notifications
You must be signed in to change notification settings - Fork 936
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 all 'assigned but unused variable' warnings #1551
Conversation
The formatting differences are likely due to using a newer version of rufo
- The variables in content_location_parser appear to have been copied from content_disposition_parser but are unused - Ragel seems to always generate a useless testEof variable. The `if false` trick is also used in whitequark/parser@21581a2 to suppress the warning. As mentioned in the parser commit, `if false` will not actually generate instructions and so it has no runtime cost. Co-authored-by: Guilherme Quirino <guilhermequirino74@gmail.com>
I tried to wrap my head around the An example is this: # lib/mail/parsers/content_location_parser.rb
when 17
# line 24 "lib/mail/parsers/rfc5322_lexical_tokens.rl"
begin
begin
stack[top] = cs
top += 1
cs = 20
_goto_level = _again
next
end
end
# line 20 "lib/mail/parsers/content_location_parser.rl"
begin
content_location.location = chars(data, token_string_s, p - 1)
end The comments indicate that the first block is generated by Mostly just dumping some thoughts, I think this PR should be merged whether or not the other warnings are addressed. |
I wondered about that too at first. I think the warning is caused by the use of an unconditional 'next' which presumably terminates the 'when' block, so line 20 is not reached. |
I wonder if it is worth fixing the warnings, given that the files are automatically generated. It might be better to set things up so warnings are not generated for these files. |
Previously, requiring any of the ragel generated parsers in mail would output tons of warnings in tests, making output much harder to read (especially in Railties). This commit extends the RaiseWarnings patch to suppress output from these mail parsers. The suppression can be removed once mikel/mail#1557 or mikel/mail#1551 or any other PR fixes the issue
Since the I opened #1557 as another potential method to silence warnings, but someone pointed out to me that changing a global variable in that way is not thread safe. Whether or not we find a solution to unreachable statement warnings, I think this change is worth merging as it is an improvement on the current situation. |
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.
Looks OK to me
Thanks! |
if false
trick is also used in whitequark/parser@21581a2 to suppress the warning. As mentioned in the parser commit,if false
will not actually generate instructions and so it has no runtime cost.The first commit is simply running
rake ragel
again to regenerate the parsersFixes #1400 (I've added @GQuirino as a Co-Author)