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.
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
Add strict-inference specification #518
Add strict-inference specification #518
Changes from 3 commits
336f596
9b3d1cd
350c7bb
1ebb431
b10e09f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't quite an accurate description of what happens. What happens is that the downwards context provides no information. Upwards inference constrains
T
to be a super type ofbool
from the first argument. For the second argument, inference assumes thats
andx
have typedynamic
, and hence infersdynamic Function(dynamic, int)
as the type of the function literal. This in turn constraintsT
to be a supertype ofdynamic
. The LUB ofbool
anddynamic
isdynamic
, and so that is what is chosen forT
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK that makes sense. I think I've corrected my paragraph.
I'm hesitant to use the word "assumes" here, as I don't think that's defined :). But I think I understand that this is merely another round of inference, where inference says "I need to know the type of
(s, x) => s + x
and all I know is? Function(?, int)
so you don't get anything from above" and this new round of inference says "Well garbage in, garbage out, friend; I've got nothing either, so you getdynamic Function(dynamic, int)
", and I assume they both have New York accents.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you intended to say a little more than that (here and elsewhere). Specifically "inferred as something other than
dynamic
".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even dynamic would be fine. For example:
Strict inference will not report any inference failures; the parameter type on the second line is inferred to be dynamic. The first line is filled with explicit dynamics.
Or the method case: