From 4ca026cee56ba5e01df2e7812f0d1e731e2c1245 Mon Sep 17 00:00:00 2001 From: Tom Stuart Date: Tue, 15 Dec 2020 10:27:25 +0000 Subject: [PATCH] =?UTF-8?q?Raise=20SyntaxError=20on=20pattern=20match=20if?= =?UTF-8?q?=20the=20feature=20isn=E2=80=99t=20enabled?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../java/org/truffleruby/parser/BodyTranslator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/truffleruby/parser/BodyTranslator.java b/src/main/java/org/truffleruby/parser/BodyTranslator.java index 3df33e33e9af..327e87646acb 100644 --- a/src/main/java/org/truffleruby/parser/BodyTranslator.java +++ b/src/main/java/org/truffleruby/parser/BodyTranslator.java @@ -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());