Skip to content

Commit 2c16533

Browse files
committed
Unwrapp PatternNode wrapped with ParenthesesNode
1 parent bd14fda commit 2c16533

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/repl_type_completor/type_analyzer.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,8 @@ def evaluate_case_in_condition(target, node, scope)
971971
end
972972

973973
def evaluate_match_pattern(value, pattern, scope)
974+
pattern = pattern.body while pattern.is_a?(Prism::ParenthesesNode)
975+
974976
# TODO: scope.terminate_with Scope::PATTERNMATCH_BREAK, Types::NIL
975977
case pattern
976978
when Prism::FindPatternNode

test/repl_type_completor/test_type_analyze.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ def test_pattern_match
660660
assert_call('1 in a; a.', include: Integer)
661661
assert_call('a=1; x in String=>a; a.', include: [Integer, String])
662662
assert_call('a=1; x=>String=>a; a.', include: String, exclude: Integer)
663+
assert_call('x in (((String)|Integer))=>a; a.', include: [String, Integer])
663664
end
664665

665666
def test_bottom_type_termination

0 commit comments

Comments
 (0)