Skip to content

Commit

Permalink
Merge pull request #552 from soutaro/rest-keyword-params
Browse files Browse the repository at this point in the history
Fix method parameter type checking
  • Loading branch information
soutaro committed May 12, 2022
2 parents 9b5bc0c + 3de467e commit ec2061a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/steep/type_inference/method_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ def self.build(node:, method_type:)
when Interface::Function::Params::PositionalParams::Rest
rest_types << param.type
positional_params = nil
args.shift
break
when nil
has_error = true
Expand Down
26 changes: 26 additions & 0 deletions test/type_construction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8796,4 +8796,30 @@ class Foo < Class.new
end
end
end

def test_keyword_param_methods
with_checker(<<-RBS) do |checker|
module KeywordParamMethod
class Foo
def bar: (*String, name: Symbol) -> void
end
end
RBS

source = parse_ruby(<<-'RUBY')
module KeywordParamMethod
class Foo
def bar(*args, name:)
end
end
end
RUBY

with_standard_construction(checker, source) do |construction, typing|
construction.synthesize(source.node)

assert_no_error(typing)
end
end
end
end

0 comments on commit ec2061a

Please sign in to comment.