diff options
author | jcosborn <jcosborn@users.noreply.github.com> | 2017-12-09 06:07:37 -0600 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-12-09 13:07:37 +0100 |
commit | 96a5062b8cdc8a8c4ceeff2acd99ffde0ce6be96 (patch) | |
tree | 01f7b47f6616c83bce991a65b00bf29d49e385c4 | |
parent | b87ef6553201c73e24b1b53641cc18abe17d6e9b (diff) | |
download | Nim-96a5062b8cdc8a8c4ceeff2acd99ffde0ce6be96.tar.gz |
modify getTypeImpl to reduce result to final implementation (#6891)
* added test case for getTypeImpl * modify getTypeImpl to reduce result to final implementation
-rw-r--r-- | compiler/vmdeps.nim | 6 | ||||
-rw-r--r-- | tests/macros/tgettypeinst.nim | 14 |
2 files changed, 15 insertions, 5 deletions
diff --git a/compiler/vmdeps.nim b/compiler/vmdeps.nim index 44550a389..fb277272b 100644 --- a/compiler/vmdeps.nim +++ b/compiler/vmdeps.nim @@ -84,10 +84,10 @@ proc mapTypeToAstX(t: PType; info: TLineInfo; if inst: if t.sym != nil: # if this node has a symbol - if allowRecursion: # getTypeImpl behavior: turn off recursion - allowRecursion = false - else: # getTypeInst behavior: return symbol + if not allowRecursion: # getTypeInst behavior: return symbol return atomicType(t.sym) + #else: # getTypeImpl behavior: turn off recursion + # allowRecursion = false case t.kind of tyNone: result = atomicType("none", mNone) diff --git a/tests/macros/tgettypeinst.nim b/tests/macros/tgettypeinst.nim index ea98721c4..2f1abe193 100644 --- a/tests/macros/tgettypeinst.nim +++ b/tests/macros/tgettypeinst.nim @@ -113,8 +113,12 @@ type Generic[T] = seq[int] Concrete = Generic[int] + Generic2[T1, T2] = seq[T1] + Concrete2 = Generic2[int, float] + Alias1 = float Alias2 = Concrete + Alias3 = Concrete2 Vec[N: static[int],T] = object arr: array[N,T] @@ -154,15 +158,21 @@ test(Tree): left: ref Tree right: ref Tree test(Concrete): - type _ = Generic[int] + type _ = seq[int] test(Generic[int]): type _ = seq[int] test(Generic[float]): type _ = seq[int] +test(Concrete2): + type _ = seq[int] +test(Generic2[int,float]): + type _ = seq[int] test(Alias1): type _ = float test(Alias2): - type _ = Generic[int] + type _ = seq[int] +test(Alias3): + type _ = seq[int] test(Vec[4,float32]): type _ = object arr: array[0..3,float32] |