Fix fromPreserve for distinct types

This is an example of why bypassing the type system with "when"
is dangerous.
This commit is contained in:
Emery Hemingway 2022-02-11 15:36:30 -06:00
parent 1cf0df255f
commit 6c4cfa0885
1 changed files with 1 additions and 1 deletions

View File

@ -780,7 +780,7 @@ proc fromPreserve*[T, E](v: var T; pr: Preserve[E]): bool =
elif compiles(fromPreserveHook(v, pr)):
result = fromPreserveHook(v, pr)
elif T is distinct:
result = fromPreserve(result.distinctBase, pr)
result = fromPreserve(v.distinctBase, pr)
elif T is enum:
if pr.isSymbol:
try: