Skip to content

Commit

Permalink
Raise SyntaxError on pattern match if the feature isn’t enabled
Browse files Browse the repository at this point in the history
The message is “syntax error, unexpected keyword_in” because that’s what
TruffleRuby (without pattern matching support) currently raises.

# Conflicts:
#	src/main/java/org/truffleruby/parser/BodyTranslator.java
  • Loading branch information
tomstuart committed Dec 16, 2020
1 parent 1314c85 commit 4ca026c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/truffleruby/parser/BodyTranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,16 @@ public RubyNode visitCaseNode(CaseParseNode node) {

@Override
public RubyNode visitCaseInNode(CaseInParseNode node) {
if (!language.options.PATTERN_MATCHING) {
final RubyContext context = RubyLanguage.getCurrentContext();
throw new RaiseException(
context,
context.getCoreExceptions().syntaxError(
"syntax error, unexpected keyword_in",
currentNode,
node.getPosition().toSourceSection(source)));
}

final SourceIndexLength sourceSection = node.getPosition();

RubyNode elseNode = translateNodeOrNil(sourceSection, node.getElseNode());
Expand Down

0 comments on commit 4ca026c

Please sign in to comment.