diff options
author | andri lim <jangko128@gmail.com> | 2018-05-29 14:38:52 +0700 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-05-29 09:38:52 +0200 |
commit | 25a41d5d90c707e8d926308c495c95e2cd13d984 (patch) | |
tree | f1b6c7fc83df9891fa5dc840476d822256d682ae /tests/array | |
parent | a075a912cfaba685ad1ba9e41d046265fdf104b8 (diff) | |
download | Nim-25a41d5d90c707e8d926308c495c95e2cd13d984.tar.gz |
fixes #7818, correct internal representation of generic objects array construction (#7824)
* defer skiptypes * defer skiptypes for tyRef & tyPtr * remove unneeded skipTypes
Diffstat (limited to 'tests/array')
-rw-r--r-- | tests/array/t7818.nim | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/array/t7818.nim b/tests/array/t7818.nim new file mode 100644 index 000000000..5d73efec5 --- /dev/null +++ b/tests/array/t7818.nim @@ -0,0 +1,45 @@ +discard """ + msg: '''BracketExpr + Sym "array" + Infix + Ident ".." + IntLit 0 + IntLit 2 + BracketExpr + Sym "Vehicle" + Sym "int" +--------- +BracketExpr + Sym "array" + Infix + Ident ".." + IntLit 0 + IntLit 2 + BracketExpr + Sym "Vehicle" + Sym "int" +---------''' +""" + +# bug #7818 +# this is not a macro bug, but array construction bug +# I use macro to avoid object slicing +# see #7712 and #7637 +import macros + +type + Vehicle[T] = object of RootObj + tire: T + Car[T] = object of Vehicle[T] + Bike[T] = object of Vehicle[T] + +macro peek(n: typed): untyped = + echo getTypeImpl(n).treeRepr + echo "---------" + +var v = Vehicle[int](tire: 3) +var c = Car[int](tire: 4) +var b = Bike[int](tire: 2) + +peek([c, b, v]) +peek([v, c, b]) |