next steps for closure iterators
This commit is contained in:
parent
85a5bfe605
commit
37229df7fc
28 changed files with 164 additions and 71 deletions
17
tests/objects/tobjcov.nim
Normal file
17
tests/objects/tobjcov.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Covariance is not type safe:
|
||||
|
||||
type
|
||||
TA = object of TObject
|
||||
a: int
|
||||
TB = object of TA
|
||||
b: array[0..5000_000, int]
|
||||
|
||||
proc ap(x: var TA) = x.a = -1
|
||||
proc bp(x: var TB) = x.b[high(x.b)] = -1
|
||||
|
||||
# in Nimrod proc (x: TB) is compatible to proc (x: TA),
|
||||
# but this is not type safe:
|
||||
var f = cast[proc (x: var TA) {.nimcall.}](bp)
|
||||
var a: TA
|
||||
f(a) # bp expects a TB, but gets a TA
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue