You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the problem comes from the fact that foo don't have explicit arguments, and so consider that the size it produce should be global, even if it in fact depends of the polymorphic argument n, then f1s and f2s are wrongly considered of same size...
Yes, we've had other bugs related to the fact that polymorphic bindings are essentially functions.
How do we fix this? One problem is that we don't have anywhere to plug in unknown sizes that are produced by polymorphic instantiation. Specifically, a Var is not an AppExp. It could become one, of course.
We could also simply ban polymorphic values from having an existential type. It's probably not useful. I want to keep both polymorphic values and existential values, but they are on their own somewhat rare features, and their combination is highly unusual.
Maybe we can consider the size parameters as parameters for the checking of adding the unknown or not ?
If Apply was not requiring a NE.NonEmpty of arguments, we could then have done a case of variable typing so that if a variable is polymorphic with existential type, it is converted to function application with 0 argument. Else I don't really know how to deal with these.
Making Var an AppExp sounds like a bit too much for such a specific (and contrived) case, I don't think its the right thing to do. Or, if it is done, it should probably be the case for every construction, which lead to deep reworking of typing and internalisation, so should probably not be done just for this reason.
Note that formalisation forbid this, even if we could have authorized them, as every construction act like AppExp in it.
The most principled solution is to make Var an AppExp. The easiest solution is to forbid the definition of foo. Sometimes it's better to impose a somewhat ad-hoc restriction in order to keep the implementation simpler.
This program should not type, but it does (the compiler even manage to produce code):
I think the problem comes from the fact that
foo
don't have explicit arguments, and so consider that the size it produce should be global, even if it in fact depends of the polymorphic argumentn
, thenf1s
andf2s
are wrongly considered of same size...This can be easily seen in the typing production:
version commit:
The text was updated successfully, but these errors were encountered: