close #2882
This commit is contained in:
parent
189d28672c
commit
bec7f9398f
1 changed files with 33 additions and 1 deletions
|
|
@ -6,7 +6,10 @@ true
|
||||||
p has been called.
|
p has been called.
|
||||||
p has been called.
|
p has been called.
|
||||||
implicit generic
|
implicit generic
|
||||||
generic'''
|
generic
|
||||||
|
false
|
||||||
|
true
|
||||||
|
-1'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# https://github.com/nim-lang/Nim/issues/1147
|
# https://github.com/nim-lang/Nim/issues/1147
|
||||||
|
|
@ -66,3 +69,32 @@ c1(@[1])
|
||||||
proc c2[T](x: Container[T]) = echo "generic"
|
proc c2[T](x: Container[T]) = echo "generic"
|
||||||
c2(@[1])
|
c2(@[1])
|
||||||
|
|
||||||
|
# https://github.com/nim-lang/Nim/issues/2882
|
||||||
|
type
|
||||||
|
Paper = object
|
||||||
|
name: string
|
||||||
|
|
||||||
|
Bendable = concept x
|
||||||
|
bend(x is Bendable)
|
||||||
|
|
||||||
|
proc bend(p: Paper): Paper = Paper(name: "bent-" & p.name)
|
||||||
|
|
||||||
|
var paper = Paper(name: "red")
|
||||||
|
echo paper is Bendable
|
||||||
|
|
||||||
|
type
|
||||||
|
A = concept self
|
||||||
|
size(self) is int
|
||||||
|
|
||||||
|
B = object
|
||||||
|
|
||||||
|
proc size(self: B): int =
|
||||||
|
return -1
|
||||||
|
|
||||||
|
proc size(self: A): int =
|
||||||
|
return 0
|
||||||
|
|
||||||
|
let b = B()
|
||||||
|
echo b is A
|
||||||
|
echo b.size()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue