-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
The following code reports false, true when the expected result is true, true:
import os, posix
type
Reader = concept c
c.read(openarray[byte], int, int) is int
Rdr = concept c
c.rd(openarray[byte], int, int) is int
type
TestFile = object
proc read(r: TestFile, dest: openarray[byte], offset: int, limit: int): int =
result = 0
proc rd(r: TestFile, dest: openarray[byte], offset: int, limit: int): int =
result = 0
when isMainModule:
echo TestFile is Reader, ", ", TestFile is RdrHowever, if you exclude posix.read from being imported it works:
import os
import posix except read
type
Reader = concept c
c.read(openarray[byte], int, int) is int
Rdr = concept c
c.rd(openarray[byte], int, int) is int
type
TestFile = object
proc read(r: TestFile, dest: openarray[byte], offset: int, limit: int): int =
result = 0
proc rd(r: TestFile, dest: openarray[byte], offset: int, limit: int): int =
result = 0
when isMainModule:
echo TestFile is Reader, ", ", TestFile is RdrAnother interesting case is the following:
import os
from posix import nil
type
Reader = concept c
c.read(openarray[byte], int, int) is int
Rdr = concept c
c.rd(openarray[byte], int, int) is int
Closer = concept c
c.close()
type
TestFile = object
proc read(r: TestFile, dest: openarray[byte], offset: int, limit: int): int =
result = 0
proc rd(r: TestFile, dest: openarray[byte], offset: int, limit: int): int =
result = 0
proc close(r: TestFile) =
discard
when isMainModule:
echo TestFile is Reader, ", ", TestFile is Rdr
echo TestFile is CloserI would expect an output of
true, true
true
But instead get
true, true
false
Perhaps this second case is a misunderstanding on my part...