Open mcclure opened 8 years ago
There is no reason (1.) cannot work here. :-)
Cool.
By the way, I came up with a simpler test case where sequtils is not required.
proc dothis[T](data: T, op: proc (x: T) {.closure.}) =
op(data)
type
A = ref object of RootObj
B = ref object of A
method identify(a:A) {.base.} = echo "A"
method identify(b:B) = echo "B"
var b:B; b.new
var a:A = b
dothis(a, identify)
dothis(a, proc(x:A) = x.identify)
Expected: B\nB
Observed: A\nB
Replacing ".closure." with ".nimcall." or removing the "{.closure.}" annotation altogether produces the same results.
This issue has been automatically marked as stale because it has not had recent activity. If you think it is still a valid issue, write a comment below; otherwise it will be closed. Thank you for your contributions.
Following is with Nim built from git:07d7d35d995262830
Consider this code:
Observed behavior: This program prints
There are no warnings or errors, even on verbosity:2. If instead of importing map from sequtils I copy the body of sequtils.map directly into this program, I get the same behavior.
Expected behavior: One of the following should be true:
returnself
) into a place where methods cannot be correctly accepted (such asmap
). Moreover, the manual should clearly describe under "multi-methods" under which circumstances methods will break in this fashion.