Propagate newline from if to bodies#9355
Open
headius wants to merge 1 commit intojruby:jruby-10.0from
Open
Conversation
This is a somewhat form-fitted fix for jruby#9293 that only assists with line numbers of the then and else bodies of IfNode. In the linked issue, a trailing `if` or `unless` modifier will be used as the line number that an associated call gets associated with, causing stack output like from `caller_locations` to be incorrect. In CRuby, this newline propagation appears to be done during the `reduce_nodes` function, but that function has many side effects in its macro-heavy logic and an initial attempt to port it did not fix the issue in question. Instead, I just detect this specific case and propagate the newline manually. There may be other such cases, and once we encounter those there may be a better justification for formally duplicating the newline side-effect logic from `reduce_node`. For now, this quick fix is probably good enough. Fixes jruby#9293
cdf17ef to
31d1685
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a somewhat form-fitted fix for #9293 that only assists with line numbers of the then and else bodies of IfNode. In the linked issue, a trailing
iforunlessmodifier will be used as the line number that an associated call gets associated with, causing stack output like fromcaller_locationsto be incorrect. In CRuby, this newline propagation appears to be done during thereduce_nodesfunction, but that function has many side effects in its macro-heavy logic and an initial attempt to port it did not fix the issue in question. Instead, I just detect this specific case and propagate the newline manually.There may be other such cases, and once we encounter those there may be a better justification for formally duplicating the newline side-effect logic from
reduce_node. For now, this quick fix is probably good enough.Fixes #9293