diff options
author | Zahary Karadjov <zahary@gmail.com> | 2016-07-30 13:21:14 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2017-03-24 16:58:15 +0200 |
commit | 33f4e69759820021f6b5089fe3798233b2a1fb13 (patch) | |
tree | e84e80adb2d2aedf030d9df643098513982aa4e9 /tests | |
parent | eab1d0cc02beaa2f749725e2c3d8f19bb792a24c (diff) | |
download | Nim-33f4e69759820021f6b5089fe3798233b2a1fb13.tar.gz |
support for accessing types and consts defined in concepts with the dot operator
Diffstat (limited to 'tests')
-rw-r--r-- | tests/concepts/tstackconcept.nim | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/concepts/tstackconcept.nim b/tests/concepts/tstackconcept.nim index dc75df5ff..11d6505cf 100644 --- a/tests/concepts/tstackconcept.nim +++ b/tests/concepts/tstackconcept.nim @@ -2,11 +2,15 @@ discard """ output: "20\n10" msg: ''' INFERRED int +VALUE TYPE int +VALUE TYPE NAME INT IMPLICIT INFERRED int int +IMPLICIT VALUE TYPE int int +IMPLICIT VALUE TYPE NAME INT INT ''' """ -import typetraits +import typetraits, strutils template reject(e: expr) = static: assert(not compiles(e)) @@ -26,14 +30,23 @@ type s.push(T) s.pop() is T + type ValueType = T + const ValueTypeName = T.name.toUpper + proc genericAlgorithm[T](s: var Stack[T], y: T) = - static: echo "INFERRED ", T.name + static: + echo "INFERRED ", T.name + echo "VALUE TYPE ", s.ValueType.name + echo "VALUE TYPE NAME ", s.ValueTypeName s.push(y) echo s.pop proc implicitGeneric(s: var Stack): auto = - static: echo "IMPLICIT INFERRED ", s.T.name, " ", Stack.T.name + static: + echo "IMPLICIT INFERRED ", s.T.name, " ", Stack.T.name + echo "IMPLICIT VALUE TYPE ", s.ValueType.name, " ", Stack.ValueType.name + echo "IMPLICIT VALUE TYPE NAME ", s.ValueTypeName, " ", s.ValueTypeName return s.pop() |