Forbid reopening generic types with different type var splats #10167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The following (taken from specs) currently compiles:
This is misleading because when reopening a generic class/struct the compiler already checks the arity and the names of the formal type vars, but not the splat indices, which affect how many type vars are allowed in instantiations and which formal vars they are bound to. This patch rejects code like the above. (It remains possible to reopen a generic type with omitted type vars.)
Notice how I said "class/struct"; Crystal performs no checks on reopened generic modules, not even their arity. This patch also adds them.