diff options
Diffstat (limited to 'tests/generics/tgenerics_issues.nim')
-rw-r--r-- | tests/generics/tgenerics_issues.nim | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/tests/generics/tgenerics_issues.nim b/tests/generics/tgenerics_issues.nim index 365afd407..3068a22f2 100644 --- a/tests/generics/tgenerics_issues.nim +++ b/tests/generics/tgenerics_issues.nim @@ -24,9 +24,9 @@ G:0,1:0.1 G:0,1:0.1 H:1:0.1 0 -(foo: None[seq[Foo]], s: "") -(foo: Some(@[(a: "world", bar: None[Bar])]), s: "hello,") -@[(a: "hey", bar: None[Bar])] +(foo: none(seq[Foo]), s: "") +(foo: some(@[(a: "world", bar: none(Bar))]), s: "hello,") +@[(a: "hey", bar: none(Bar))] ''' joinable: false """ @@ -603,7 +603,7 @@ block t7854: block t5864: - proc defaultStatic(s: openarray, N: static[int] = 1): int = N + proc defaultStatic(s: openArray, N: static[int] = 1): int = N proc defaultGeneric[T](a: T = 2): int = a let a = [1, 2, 3, 4].defaultStatic() @@ -774,13 +774,13 @@ block: # issue #9458 Option[T] = object val: T has: bool - + Bar = object proc none(T: typedesc): Option[T] = discard - proc foo[T](self: T; x: Option[Bar] = Bar.none) = + proc foo[T](self: T; x: Option[Bar] = Bar.none) = discard foo(1) @@ -834,7 +834,7 @@ proc getBar(x: string): Bar = Bar(foo: none[seq[Foo]](), s: "") -proc fakeReadLine(): TaintedString = "hey" +proc fakeReadLine(): string = "hey" echo getBar(fakeReadLine()) # causes error @@ -860,3 +860,35 @@ type var a: Tile3[int] +block: # Ensure no segfault from constraint + type + Regex[A: SomeOrdinal] = ref object + val: Regex[A] + MyConstraint = (seq or enum or set) + MyOtherType[A: MyConstraint] = ref object + val: MyOtherType[A] + + var + a = Regex[int]() + b = Regex[bool]() + c = MyOtherType[seq[int]]() + +block: # https://github.com/nim-lang/Nim/issues/20416 + type + Item[T] = object + link:ptr Item[T] + data:T + + KVSeq[A,B] = seq[(A,B)] + + MyTable[A,B] = object + data: KVSeq[A,B] + + Container[T] = object + a: MyTable[int,ref Item[T]] + + proc p1(sg:Container) = discard # Make sure that a non parameterized 'Container' argument still compiles + + proc p2[T](sg:Container[T]) = discard + var v : Container[int] + p2(v) |