Skip to content

feat: clarify interaction between nullability binding and any type parameters#960

Open
benbellick wants to merge 8 commits intomainfrom
benbellick/clarify-type-parameter-nullability
Open

feat: clarify interaction between nullability binding and any type parameters#960
benbellick wants to merge 8 commits intomainfrom
benbellick/clarify-type-parameter-nullability

Conversation

@benbellick
Copy link
Copy Markdown
Member

@benbellick benbellick commented Feb 18, 2026

  • Document how nullability mode (MIRROR, DECLARED_OUTPUT, DISCRETE) interacts with any[\d] type parameter binding
  • Add concrete examples showing outermost vs inner nullability, compound types, cross-structural binding, and DISCRETE matching

Closes #943


This change is Reviewable

@benbellick benbellick changed the title docs: clarify nullability binding for any type parameters feat: clarify interaction between nullability binding and any type parameters Feb 18, 2026
@benbellick
Copy link
Copy Markdown
Member Author

I am aware of the complexity added here. If someone can think of a better way to manage this complexity, that would be much preferred. The fundamental problem is dealing with how nullabilityHandling interacts with binding to any type parameters. #949 clarified that with nullability handling MIRROR and DECLARED_OUTPUT, the formal parameters must not have nullability markers. However, nothing stops us from passing in arguments that contain nullability arguments.

This PR is a stab at addressing this interaction.

There is also the case of DISCRETE which is accounted for here. The approach is to just say that the outermost nullability must be declared explicitly and must match when invoked.

Copy link
Copy Markdown
Contributor

@Slimsammylim Slimsammylim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanations and examples here are very clear and make sense to me. My only nit is I prefer if the all the reason boxes are filled, but that's just because I like when explanations are obvious. Either way is good!

@benbellick
Copy link
Copy Markdown
Member Author

@Slimsammylim I added them, good suggestion!

@benbellick benbellick marked this pull request as ready for review March 6, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify whether any[\d] type parameters can bind arguments with differing outermost nullability

3 participants