Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- ruby*.y: fixed context inside lambda args and module. (#709)
Previously we didn't push context for module and lambda arguments and so we didn't reject some code (or we rejected what's allowed). However, examples that should've raised errors are complicated and it's very unlikely that any code was affected. At least no related issues were reported. Examples of code that is accepted/rejected differently after this change: 1. `->(a) { module M; _1; end }` We didn't push context for module M, and so argument a conflicted with implicit parameter `_1`. In Ruby module opens a new scope and so `_1` is just a regular local variable. 2. `class A; ->(a = (return; 1)) {}; end` This code is valid, because return is a part of the lambda. But we didn't store this fact internally, and so it was rejected before. Both examples described above (and all similar variations) are fixed in this commit. Also, slightly improved assertions related to context (`assert_context`). Instead of checking state of the half-reduced AST (which is impossible for lambda args for example) we use a special get_context macro-like node that grabs snapshot of the `parser.context`.
- Loading branch information
1 parent
b5c1fb4
commit bc20734
Showing
18 changed files
with
273 additions
and
78 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.