diff --git a/lib/katakata_irb/type_analyzer.rb b/lib/katakata_irb/type_analyzer.rb index 6fff938..02ef638 100644 --- a/lib/katakata_irb/type_analyzer.rb +++ b/lib/katakata_irb/type_analyzer.rb @@ -932,13 +932,7 @@ def assign_numbered_parameters(numbered_parameters, scope, args, _kwargs) return if numbered_parameters.empty? max_num = numbered_parameters.map { _1[1].to_i }.max if max_num == 1 - if args.size == 0 - scope['_1'] = KatakataIrb::Types::NIL - elsif args.size == 1 - scope['_1'] = args.first - else - scope['_1'] = KatakataIrb::Types.array_of(*args) - end + scope['_1'] = args.first || KatakataIrb::Types::NIL else args = sized_splat(args.first, :to_ary, max_num) if args.size == 1 numbered_parameters.each do |name| diff --git a/test/test_type_analyze.rb b/test/test_type_analyze.rb index 9cf374a..0edab8c 100644 --- a/test/test_type_analyze.rb +++ b/test/test_type_analyze.rb @@ -518,9 +518,12 @@ def test_numbered_parameter assert_call('loop{_1.', include: NilClass) assert_call('1.tap{_1.', include: Integer) assert_call('1.tap{_3.', include: NilClass, exclude: Integer) - assert_call('[:a].each_with_index{_1.', include: Array) - assert_call('[:a].each_with_index{_2; _1.', include: Symbol) - assert_call('[:a].each_with_index{_2.', include: Integer) + assert_call('[:a,1].tap{_1.', include: Array, exclude: [Integer, Symbol]) + assert_call('[:a,1].tap{_2.', include: [Symbol, Integer], exclude: Array) + assert_call('[:a,1].tap{_2; _1.', include: [Symbol, Integer], exclude: Array) + assert_call('[:a].each_with_index{_1.', include: Symbol, exclude: [Integer, Array]) + assert_call('[:a].each_with_index{_2; _1.', include: Symbol, exclude: [Integer, Array]) + assert_call('[:a].each_with_index{_2.', include: Integer, exclude: Symbol) end def test_if_unless