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
Spurious ability check failure here #4084
Comments
Some notes: synthesizeWanted tm@(Term.Apps' f args) = do
-- ->EEEEE
(ft, fwant) <- synthesize f
ctx <- getContext
(vs, ft) <- ungeneralize' ft -- Is this line correct? Seems unnecessary, since synthesizeApp will unroll the forall
(at, awant) <-
scope (InFunctionCall vs f ft args) $
synthesizeApps tm (apply ctx ft) args
(at,) <$> coalesceWanted awant fwant The other thing is we will presumably end up here in go (Type.Arrow' i o0) = do
-- ->App
let (es, o) = Type.stripEffect o0
(o,) <$> checkWantedScoped ((Just fun,) <$> es) arg i Where we'll have This seems like it reduces to |
So, here's what I think is going on. Eventually we do something like:
This then eventually does two subtype calls:
in that order. The first one triggers defaulting So, you might think, "just do the checks in the opposite order." But I think that just means you get the same error in the opposite scenario. Also, before anyone suggests One thing that might be possible is to delay ability subtyping until after the subtyping of the rest of the structure. Just collect up all the ability subtyping problems, and try to take advantage of having them all together. That way we could see that both Edit: BTW, the above is only relatively easy for a single subtype check, I think. Some type checking does not go through a single subtype check, though. For instance, if the problem involved types like |
Dan and I talked about this on a recent call. At first I was thinking "let's get rid of the slack variables" and instead do #3753. But @dolio pointed out that repeated subtype checks are fairly common and it's nice to come up with the "right" row type via incremental refinement. My other idea which we didn't really get to explore is to have "open" row types be more of a first class concept in the typechecker. Right now, we have only "closed" row types, with the "openness" represented using slack variables. This leads to proliferation of slack variables, which we try to clean up, but then that causes problems in cases like this ticket. If however, an "open" row type is represented explicitly, we could have a typing judgement which says that that open row types can be extended by a subtype check, if there are no matches in the existing set. Thus, you never create slack variables in a row type, only solved type variables. It's possible this will be better behaved, but needs more exploration. |
There seems to be no workaround (I tried putting annotations on
f
at the call site to no avail)The text was updated successfully, but these errors were encountered: