From 1145293bf50814e4088811888a964d24331109ff Mon Sep 17 00:00:00 2001 From: tompng Date: Sat, 28 Oct 2023 02:59:55 +0900 Subject: [PATCH] Fix forwarding arg bug --- lib/katakata_irb/type_analyzer.rb | 4 ++-- test/test_type_analyze.rb | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/katakata_irb/type_analyzer.rb b/lib/katakata_irb/type_analyzer.rb index 02ef638..f8893d3 100644 --- a/lib/katakata_irb/type_analyzer.rb +++ b/lib/katakata_irb/type_analyzer.rb @@ -797,7 +797,7 @@ def evaluate_call_node_arguments(call_node, scope) # `f(a, ...)` treat like splat nil when Prism::SplatNode - evaluate arg.expression, scope + evaluate arg.expression, scope if arg.expression nil # TODO: splat else evaluate arg, scope @@ -815,7 +815,7 @@ def evaluate_call_node_arguments(call_node, scope) nil end when Prism::AssocSplatNode - evaluate arg.value, scope + evaluate arg.value, scope if arg.value nil end end.compact.to_h diff --git a/test/test_type_analyze.rb b/test/test_type_analyze.rb index 0edab8c..0bb2834 100644 --- a/test/test_type_analyze.rb +++ b/test/test_type_analyze.rb @@ -354,6 +354,8 @@ def test_def assert_call('def f(a,b=1,*c,d,x:0,y:,**z,&e); e.arity.', include: Integer) assert_call('def f(...); 1.', include: Integer) assert_call('def f(a,...); 1.', include: Integer) + assert_call('def f(...); g(...); 1.', include: Integer) + assert_call('def f(*,**,&); g(*,**,&); 1.', include: Integer) assert_call('class Array; def f; self.', include: Array) end