Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add doc and spec for
empty-else
node
Follow whitequark/parser#652. This PR adds doc and spec for `empty-else` node. Below is a description of `empty-else` node. > Empty `else` differs from the missing (or _implicit_) `else` for pattern > matching, since > the latter one raises a `NoMatchingPattern` exception. Thus, we need a > way to distinguish this two cases in the resulting AST. https://github.com/whitequark/parser/blob/v3.0.1.1/doc/AST_FORMAT.md#with-empty-else Below are the differences between each AST (`empty-else` only appears in the last case). ```console % ruby-parse -e 'case foo; when bar; end' (case (send nil :foo) (when (send nil :bar) nil) nil) % ruby-parse -e 'case foo; when bar; else; end' (case (send nil :foo) (when (send nil :bar) nil) nil) % ruby-parse -e 'case foo; in bar; end' (case-match (send nil :foo) (in-pattern (match-var :bar) nil nil) nil) % ruby-parse -e 'case foo; in bar; else; end' (case-match (send nil :foo) (in-pattern (match-var :bar) nil nil) (empty-else)) ``` This PR has also added a spec for `CaseNode` to clarify the difference in behavior.
- Loading branch information