add testcase for #7308 (#18849)

This commit is contained in:
flywind
2021-09-15 01:39:55 +08:00
committed by GitHub
parent 172253cb55
commit bf1700bab1
2 changed files with 43 additions and 11 deletions

View File

@@ -463,14 +463,3 @@ proc putValue[T](n: T) =
echo b.n
useForward()
# bug #16246
proc testWeirdTypeAliases() =
var values = newSeq[cuint](8)
# var values: seq[cuint] does not produce codegen error
var drawCb = proc(): seq[uint32] =
result = newSeq[uint32](10)
testWeirdTypeAliases()

43
tests/ccgbugs/tctypes.nim Normal file
View File

@@ -0,0 +1,43 @@
discard """
targets: "c cpp"
matrix: "--gc:refc; --gc:arc"
"""
# bug #7308
proc foo(x: seq[int32]) =
var y = newSeq[cint](1)
proc bar =
var t = newSeq[int32](1)
foo(t)
bar()
# bug #16246
proc testWeirdTypeAliases() =
var values = newSeq[cuint](8)
# var values: seq[cuint] does not produce codegen error
var drawCb = proc(): seq[uint32] =
result = newSeq[uint32](10)
testWeirdTypeAliases()
block: # bug #11797
block:
type cdouble2 = cdouble
type Foo1 = seq[cdouble]
type Foo2 = seq[cdouble2]
static: doAssert Foo1 is Foo2
var a1: Foo1
var a2: Foo2
doAssert a1 == @[]
doAssert a2 == @[]
block:
proc foo[T: int|cint](fun: proc(): T) = discard
proc foo1(): cint = 1
proc foo3(): int32 = 2
foo(proc(): cint = foo1())
foo(proc(): int32 = foo3())