Conversation
Owner
soutaro
commented
Jan 7, 2025
- The length of the tuple types must be same
- Record type with additional key cannot be a subtype of another record type
rhiroe
added a commit
to rhiroe/steep
that referenced
this pull request
Feb 26, 2026
When an array literal appears in an if-branch and the expected return type is a union of tuple types (e.g. [":", ".#"] | [".#", ":"]), the type checker was incorrectly inferring [::String, ::String] instead of the correct literal tuple type. The root cause: #try_tuple_type returns a Pair even when the inferred type doesn't match the given tuple hint. Previously, the first non-nil pair was accepted unconditionally, so ['.#', ':'] tried against hint [":", ".#"] produced [::String, ::String], which was accepted instead of trying the next hint [".#", ":"]. Fix: validate each candidate pair with a subtype check against the specific tuple hint. If no candidate passes the check, fall back to the first candidate (to preserve the FalseAssertion diagnostic for cases like [1, ""] #: [1, "", bool]). Fixes the regression introduced by soutaro#1460 (Strict record and tuple subtyping).
rhiroe
added a commit
to rhiroe/steep
that referenced
this pull request
Feb 26, 2026
When an array literal appears in an if-branch and the expected return type is a union of tuple types (e.g. ["yes", "ok"] | ["no", "error"]), the type checker was incorrectly inferring [::String, ::String] instead of the correct literal tuple type. The root cause: #try_tuple_type returns a Pair even when the inferred type does not match the given tuple hint. Previously, the first non-nil pair was accepted unconditionally, so ["no", "error"] tried against hint ["yes", "ok"] produced [::String, ::String], which was accepted instead of trying the next hint ["no", "error"]. Fix: validate each candidate pair with a subtype check against the specific tuple hint. If no candidate passes the check, fall back to the first candidate (to preserve the FalseAssertion diagnostic for cases like [1, ""] #: [1, "", bool]). Fixes the regression introduced by soutaro#1460 (Strict record and tuple subtyping).
rhiroe
added a commit
to rhiroe/steep
that referenced
this pull request
Feb 26, 2026
When an array literal appears in an if-branch and the expected return type is a union of tuple types (e.g. `["yes", "ok"]` | `["no", "error"]`), the type checker was incorrectly inferring `[::String, ::String]` instead of the correct literal tuple type. The root cause: `#try_tuple_type` returns a `Pair` even when the inferred type does not match the given tuple hint. Previously, the first non-nil pair was accepted unconditionally, so `["no", "error"]` tried against hint `["yes", "ok"]` produced `[::String, ::String]`, which was accepted instead of trying the next hint `["no", "error"]`. Fix: validate each candidate pair with a subtype check against the specific tuple hint. If no candidate passes the check, fall back to the first candidate (to preserve the `FalseAssertion` diagnostic for cases like `[1, ""]` `#: [1, "", bool]`). Fixes the regression introduced by soutaro#1460 (Strict record and tuple subtyping).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.