mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-30 19:23:57 +00:00
fixes #7854
This commit is contained in:
36
tests/generics/tgenerics_and_inheritance.nim
Normal file
36
tests/generics/tgenerics_and_inheritance.nim
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
# bug #7854
|
||||
|
||||
type
|
||||
Stream* = ref StreamObj
|
||||
StreamObj* = object of RootObj
|
||||
|
||||
InhStream* = ref InhStreamObj
|
||||
InhStreamObj* = object of Stream
|
||||
f: string
|
||||
|
||||
proc newInhStream*(f: string): InhStream =
|
||||
new(result)
|
||||
result.f = f
|
||||
|
||||
var val: int
|
||||
let str = newInhStream("input_file.json")
|
||||
|
||||
block:
|
||||
# works:
|
||||
proc load[T](data: var T, s: Stream) =
|
||||
discard
|
||||
load(val, str)
|
||||
|
||||
block:
|
||||
# works
|
||||
proc load[T](s: Stream, data: T) =
|
||||
discard
|
||||
load(str, val)
|
||||
|
||||
block:
|
||||
# broken
|
||||
proc load[T](s: Stream, data: var T) =
|
||||
discard
|
||||
load(str, val)
|
||||
|
||||
Reference in New Issue
Block a user