Skip to content

Commit e51608f

Browse files
committed
Add test for align_params with arity mismatch
Type params validation runs before the alignment, so the arity mismatch raises GenericParameterMismatchError instead of building a broken substitution. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TBY8ct4HpkVkZNPdsNHEDE
1 parent 5e78055 commit e51608f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

test/rbs/environment_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,9 @@ module Foo[A, B]
368368
369369
module Foo[X, Y]
370370
end
371+
372+
module Foo[X]
373+
end
371374
EOF
372375

373376
Environment::ModuleEntry.new(type_name("::Foo")).tap do |entry|
@@ -383,6 +386,16 @@ module Foo[X, Y]
383386
assert_equal RBS::Types::Variable.new(name: :B, location: nil), subst[RBS::Types::Variable.new(name: :Y, location: nil)]
384387
end
385388
end
389+
390+
Environment::ModuleEntry.new(type_name("::Foo")).tap do |entry|
391+
entry << [nil, decls[0]]
392+
entry << [nil, decls[2]]
393+
394+
# The type params validation runs before the alignment, so the arity mismatch is detected first
395+
assert_raises RBS::GenericParameterMismatchError do
396+
entry.align_params(decls[2])
397+
end
398+
end
386399
end
387400

388401
def test_absolute_type

0 commit comments

Comments
 (0)