genOf/instOf is unsound
The use of genOf/instOf can be unsound if constraints are solved in a certain order. The issue is that a variable
tymight be implicitly active if it appears in the solution ford : T(ty), and another constraintd : T'(wheretynot inT') exists. Generalization might happen before the unification. This is caught at runtime, so unsound results are never returned, but than analysis fails altogether.Possible solutions might be:
- Make
{x} : tyandd : tydifferent constraints (much like graph and resolution). Solve{x} : tyas assumptions, andd : tyas constraints. This would disallow inference from use to declaration.- Keep all variables in types active until all
d : tyconstraints are resolved. This will probably cause problems with TDNR, becaused : tydepends on resolution, which might not succeed if agenOfis somewhere in the chain.Solution 1 seems more flexible, but still might inhibit inference in method bodys which is desirable.
Submitted by Hendrik van Antwerpen on 24 June 2017 at 19:10
Log in to post comments