Skip to content

Commit d150a48

Browse files
eregonandrykonchin
authored andcommitted
Raise a proper SyntaxError for pattern matching until implemented
* The untagged spec is legitimately passing due to Prism returning the correct SyntaxError for it.
1 parent 7aa76ac commit d150a48

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

spec/tags/language/pattern_matching_tags.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
fails:Pattern matching variable pattern supports using any name with _ at the beginning in a pattern several times
22
fails:Pattern matching variable pattern supports existing variables in a pattern specified with ^ operator
33
fails:Pattern matching variable pattern allows applying ^ operator to bound variables
4-
fails:Pattern matching variable pattern requires bound variable to be specified in a pattern before ^ operator when it relies on a bound variable
54
fails:Pattern matching alternative pattern matches if any of patterns matches
65
fails:Pattern matching alternative pattern does not support variable binding
76
fails:Pattern matching alternative pattern support underscore prefixed variables in alternation

src/main/java/org/truffleruby/parser/YARPTranslator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,9 @@ public RubyNode visitCapturePatternNode(Nodes.CapturePatternNode node) {
959959

960960
@Override
961961
public RubyNode visitCaseMatchNode(Nodes.CaseMatchNode node) {
962-
return super.visitCaseMatchNode(node);
962+
var context = RubyLanguage.getCurrentContext();
963+
throw new RaiseException(context, context.getCoreExceptions()
964+
.syntaxError("`case/in` pattern matching not yet implemented", currentNode, getSourceSection(node)));
963965
}
964966

965967
@Override
@@ -2564,7 +2566,9 @@ public RubyNode visitMatchPredicateNode(Nodes.MatchPredicateNode node) {
25642566

25652567
@Override
25662568
public RubyNode visitMatchRequiredNode(Nodes.MatchRequiredNode node) {
2567-
return defaultVisit(node);
2569+
var context = RubyLanguage.getCurrentContext();
2570+
throw new RaiseException(context, context.getCoreExceptions()
2571+
.syntaxError("`=>` pattern matching not yet implemented", currentNode, getSourceSection(node)));
25682572
}
25692573

25702574
// See BodyTranslator#visitMatch2Node

0 commit comments

Comments
 (0)