Skip to content

Commit 7b70fa8

Browse files
eregonandrykonchin
authored andcommitted
Fix in {} pattern matching
1 parent 5eab6ba commit 7b70fa8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ public RubyNode visitHashPatternNode(Nodes.HashPatternNode node) {
267267
} else {
268268
throw fail(rest);
269269
}
270+
} else if (pairs.length == 0) {
271+
// rest == null && pairs.length == 0 means `in {}` which checks if empty
272+
condition = AndNodeGen.create(condition, new HashIsEmptyNode(readTemp));
270273
}
271274

272275
return assignPositionAndFlags(node, condition);

test/mri/excludes/TestPatternMatching.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
exclude :test_alternative_pattern, "/home/eregon/code/truffleruby-ws/truffleruby/test/mri/tests/ruby/test_pattern_matching.rb:204:in `test_alternative_pattern'."
2-
exclude :test_hash_pattern, "Failed assertion, no message given."
2+
exclude :test_hash_pattern, "expected: /(?:.*:[47]: warning: unused literal ignored\\n){2}/"
33
exclude :test_invalid_syntax, "/home/eregon/code/truffleruby-ws/truffleruby/test/mri/tests/ruby/test_pattern_matching.rb:1269:in `test_invalid_syntax'."
44
exclude :test_literal_value_pattern, "/home/eregon/code/truffleruby-ws/truffleruby/test/mri/tests/ruby/test_pattern_matching.rb:347:in `test_literal_value_pattern'."
55
exclude :test_single_pattern_error_alternative_pattern, "Expected Exception(NoMatchingPatternError) was raised, but the message doesn't match."

0 commit comments

Comments
 (0)