-
Notifications
You must be signed in to change notification settings - Fork 24
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
TypeVariable.nameHint
lost in constraint solving and type simplification
#39
Comments
Nice job tracing this to the root causes. I tried to fix it, but there is one more thing that's going wrong here. In fact I noticed that method type parameters don't seem to be treated correctly. class C
method Foo[A](a: A) = a + 1
//│ Defined class C
//│ Defined C.Foo: C -> int -> int Here
Very true. They should be used sparingly! |
Fix explicit method parameters (they were not rigid) Fix method signature typing level Fix typing of type ascriptions in patterns – constrain in both directions Propagates name hints more
Fix explicit method type parameters (they were not rigid) Fix method signature typing level Fix typing of type ascriptions in patterns – constrain in both directions Propagates name hints more
Man, the method typing code is quite hairy. I noticed it also performs some needless subsumption checks. It's in dire need of simplification (let's look at this in the next meeting). |
Fix explicit method type parameters (they were not rigid) Fix method signature typing level Fix typing of type ascriptions in patterns – constrain in both directions Propagates name hints more
Right... The unnecessary subsumption checks can be skipped with a guard. But ultimately refactoring should be the way to go. |
Fix explicit method type parameters (they were not rigid) Fix method signature typing level Fix typing of type ascriptions in patterns – constrain in both directions Propagates name hints more
The name hint for the type parameter
B
in the method definition is lost. I have identified two sources of this issue:nameHint
is not preserved in extrusionmlscript/shared/src/main/scala/mlscript/ConstraintSolver.scala
Line 392 in 9930721
(That's a downside of providing default arguments. You are not forced to review every invocation and provide the appropriate argument...)
nameHint
is not unified when simplifying polar variablesLooking at the debug output of the above code snippet (after fixing 1.), the name hint is still present in the canonical inferred type:
//│ Canon: ((test<> & {Test#A: (A31 -> A31), x: A31}) -> ((((A31 | α32) -> (α33 & B34)) & α35) -> α33))
But it is later simplified away since it only cooccurs with α33 in one polarity:
//│ [sub] α32 -> None, B34 -> None, α35 -> None
The text was updated successfully, but these errors were encountered: