Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type inference problem #843

Merged
merged 2 commits into from
Jul 7, 2023
Merged

Fix type inference problem #843

merged 2 commits into from
Jul 7, 2023

Conversation

soutaro
Copy link
Owner

@soutaro soutaro commented Jul 7, 2023

Nested block calls with type variable reports unexpected type error.

"".yield_self do       # { (String) -> X1 } -> X1
  123.yield_self do    # { (Integer) -> X2 } -> X2
    true               # bool
  end
end

Here, we expect the type propagation from bool to X2 to X1, but type checker first solves X2 to X1. And bool cannot be X1, because X1 is not a bound type variable in 123.yield_self call.

This PR is to limit generating constraints between X2 and X1 only if the hint (X1) is a free variable of self. (For generic classes.)

This was caused by #789.

@soutaro soutaro added this to the Steep 1.5 milestone Jul 7, 2023
@soutaro soutaro enabled auto-merge July 7, 2023 02:18
@soutaro soutaro merged commit 6619a57 into master Jul 7, 2023
20 checks passed
@soutaro soutaro deleted the fix-type-inference branch July 7, 2023 02:34
@soutaro soutaro added the Released The PR is already included in a published release label Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released The PR is already included in a published release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant