fix #9423 followup #17594: distinct generics now work in VM (#21816)

* fix #9423 distinct generics now work in vm

* fixes cpp tests

---------

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
(cherry picked from commit deaf684375)
This commit is contained in:
ringabout
2023-05-10 17:06:14 +08:00
committed by narimiran
parent 55776451b4
commit 04d0716f37
5 changed files with 40 additions and 19 deletions

View File

@@ -232,12 +232,7 @@ proc fromJson*[T](a: var T, b: JsonNode, opt = Joptions()) =
elif T is uint|uint64: a = T(to(b, uint64))
elif T is Ordinal: a = cast[T](to(b, int))
elif T is pointer: a = cast[pointer](to(b, int))
elif T is distinct:
when nimvm:
# bug, potentially related to https://github.com/nim-lang/Nim/issues/12282
a = T(jsonTo(b, distinctBase(T)))
else:
a.distinctBase.fromJson(b)
elif T is distinct: a.distinctBase.fromJson(b)
elif T is string|SomeNumber: a = to(b,T)
elif T is cstring:
case b.kind