Skip to content

Fix type inference problem on generics#609

Merged
soutaro merged 3 commits intomasterfrom
generic-type-inference-bug
Jul 20, 2022
Merged

Fix type inference problem on generics#609
soutaro merged 3 commits intomasterfrom
generic-type-inference-bug

Conversation

@soutaro
Copy link
Owner

@soutaro soutaro commented Jul 20, 2022

Fixes #595

)

if expected_block_type = block_constr.block_context.body_type
type_vars = expected_block_type.free_variables
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is the fix.

The type error is caused by type checking lambda return type with given hint, which was type variable.
The type variable in the hint doesn't make any sense, because the lambda will be type checked with the hint in next step. The change apply a substitution that replaces all type variables to untyped.

@soutaro soutaro enabled auto-merge July 20, 2022 01:15
@soutaro soutaro merged commit f890f87 into master Jul 20, 2022
@soutaro soutaro deleted the generic-type-inference-bug branch July 20, 2022 01:26
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.

Type inference for generic-type method is wrong when nil is part of the type

1 participant