RBS::InstanceVariableDuplicationError happens on double included module
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.2k
- Forks
- 256
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 37
Description
rbs validate shows RBS::InstanceVariableDuplicationError if one class includes a module twice. Is it intentional?
Problem
module M
@iv: untyped
end
class C
include M
include M
end
$ rbs -I. validate
E, [2025-04-07T15:08:43.141421 #23447] ERROR -- rbs: ./test.rbs:2:2...2:14: Duplicated instance variable name `@iv` in `::M` (RBS::InstanceVariableDuplicationError)
@iv: untyped
Real world example
I realized this problem in the following code in a real Rails application.
module M
@iv: untyped
end
module X
include M
end
class C
include M
include X
end
Our code base (unfortunately) has such code. The module M is included twice, directly and indirectly.
I guess it can happen in other cases on complex inheritance trees.
Also, the duplication is not harmful. Because these ivar definitions are the same. So I think we can suppress the error in this case.
Even if it should be an error, I think we should fix the error message because it's confusing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two RBS examples with rbs validate, then trace the validation logic that processes repeated module inclusion and instance-variable definitions. Done means the behavior for harmless duplicate inclusion is decided and the resulting validation behavior or error message is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100