@@ -388,6 +388,7 @@ module StructuralUtilities =
388388 | TupInfo of b : bool
389389 | MeasureOne
390390 | MeasureRational of int * int
391+ | UnconstrainedVar
391392 | Unsolved
392393
393394 type TypeStructure =
@@ -420,10 +421,14 @@ module StructuralUtilities =
420421 match typar.Solution with
421422 | Some ty -> yield ! accumulateTType ty
422423 | None ->
423- TypeToken.Stamp typar.Stamp
424-
425- if typar.Rigidity = TyparRigidity.Flexible then
424+ if typar.Rigidity <> TyparRigidity.Rigid then
426425 TypeToken.Unsolved
426+
427+ // We don't emit details of the constraints, just the stamp to avoid collisions.
428+ if typar.Constraints.Length > 0 then
429+ TypeToken.Stamp typar.Stamp
430+ else
431+ TypeToken.UnconstrainedVar
427432 }
428433
429434 and private accumulateTType ( ty : TType ) =
@@ -477,7 +482,7 @@ module StructuralUtilities =
477482 let private toTypeStructure ( tokens : TypeToken seq ) =
478483 let tokens = tokens |> Seq.truncate 256 |> Seq.toArray
479484
480- if Array.length tokens = 256 then
485+ if tokens.Length = 256 then
481486 PossiblyInfinite
482487 elif tokens |> Array.exists _. IsUnsolved then
483488 UnsolvedTypeStructure tokens
@@ -492,5 +497,5 @@ module StructuralUtilities =
492497 | UnsolvedTypeStructure _ -> false
493498 | _ -> true
494499
495- // Speed up repeated calls by caching results for types that yield a stable structure.
500+ // Speed up repeated calls by memoizing results for types that yield a stable structure.
496501 Extras.WeakMap.cacheConditionally shouldCache ( fun ty -> accumulateTType ty |> toTypeStructure)
0 commit comments