Handle subtype relations for converter parameters (#8248)

Fixes #7098
This commit is contained in:
LemonBoy 2018-07-09 20:05:53 +02:00 • committed by Andreas Rumpf
commit 5c5388c0a6
2 changed files with 38 additions and 2 deletions

31
tests/converter/t7098.nim Normal file
View file

@ -0,0 +1,31 @@
type
Byte* = uint8
Bytes* = seq[Byte]
BytesRange* = object
bytes: Bytes
ibegin, iend: int
proc initBytesRange*(s: var Bytes, ibegin = 0, iend = -1): BytesRange =
let e = if iend < 0: s.len + iend + 1
else: iend
assert ibegin >= 0 and e <= s.len
shallow(s)
result.bytes = s
result.ibegin = ibegin
result.iend = e
converter fromSeq*(s: Bytes): BytesRange =
var seqCopy = s
return initBytesRange(seqCopy)
type
Reader* = object
data: BytesRange
position: int
proc readerFromBytes*(input: BytesRange): Reader =
discard
let r = readerFromBytes(@[])