From 0ce961ca324ac5ac3ff13414e8c96836bebeafbc Mon Sep 17 00:00:00 2001 From: Graham Rogers Date: Sun, 5 May 2024 10:17:16 +0100 Subject: [PATCH] Support unnamed restarg --- lib/steep/type_construction.rb | 2 +- test/type_check_test.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/steep/type_construction.rb b/lib/steep/type_construction.rb index c59da954e..d8f1fdd6b 100644 --- a/lib/steep/type_construction.rb +++ b/lib/steep/type_construction.rb @@ -37,7 +37,7 @@ def inspect s + ">" end - SPECIAL_LVAR_NAMES = Set[:_, :__any__, :__skip__] + SPECIAL_LVAR_NAMES = Set[nil, :_, :__any__, :__skip__] include ModuleHelper diff --git a/test/type_check_test.rb b/test/type_check_test.rb index 68783f0ad..6d942f607 100644 --- a/test/type_check_test.rb +++ b/test/type_check_test.rb @@ -1787,6 +1787,37 @@ def bar ) end + def test_unnamed_restarg + run_type_check_test( + signatures: { + "a.rbs" => <<~RBS + class Foo + def foo: (*untyped, **untyped) -> void + + def bar: { (*untyped, **untyped) -> void } -> void + end + RBS + }, + code: { + "a.rb" => <<~RUBY + class Foo + def foo(*, **) + bar { |*, **| } + end + + def bar + end + end + RUBY + }, + expectations: <<~YAML + --- + - file: a.rb + diagnostics: [] + YAML + ) + end + def test_rescue_assignment run_type_check_test( signatures: {