summary refs log blame commit diff stats
path: root/tests/accept/compile/tobjcov.nim
blob: da34fcb600397a26620bf2a27c31f473eee504f1 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                       
# Covariance is not type safe:

type
  TA = object
    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: proc (x: var TA) = bp
var a: TA
f(a) # bp expects a TB, but gets a TA