This commit is contained in:
Araq 2015-04-24 20:28:39 +02:00
commit 2c91e999e2
3 changed files with 50 additions and 20 deletions

View file

@ -147,6 +147,7 @@ proc copyCandidate(a: var TCandidate, b: TCandidate) =
proc sumGeneric(t: PType): int =
var t = t
var isvar = 1
while true:
case t.kind
of tyGenericInst, tyArray, tyRef, tyPtr, tyDistinct, tyArrayConstr,
@ -154,8 +155,9 @@ proc sumGeneric(t: PType): int =
t = t.lastSon
inc result
of tyVar:
# but do not make 'var T' more specific than 'T'!
t = t.sons[0]
inc result
inc isvar
of tyGenericInvocation, tyTuple:
result = ord(t.kind == tyGenericInvocation)
for i in 0 .. <t.len: result += t.sons[i].sumGeneric
@ -164,7 +166,7 @@ proc sumGeneric(t: PType): int =
of tyBool, tyChar, tyEnum, tyObject, tyProc, tyPointer,
tyString, tyCString, tyInt..tyInt64, tyFloat..tyFloat128,
tyUInt..tyUInt64:
return 1
return isvar
else: return 0
#var ggDebug: bool
@ -1470,9 +1472,7 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
m.state = csNoMatch
return
if formal.typ.kind == tyVar:
if n.isLValue:
inc(m.genericMatches, 100)
else:
if not n.isLValue:
m.state = csNoMatch
return

View file

@ -11,7 +11,8 @@ ref T
123
2
1
@[123, 2, 1]'''
@[123, 2, 1]
Called!'''
"""
# Things that's even in the spec now!
@ -79,3 +80,31 @@ proc takeV[T](a: varargs[T]) =
takeV([123, 2, 1]) # takeV's T is "int", not "array of int"
echo(@[123, 2, 1])
# bug #2600
type
FutureBase* = ref object of RootObj ## Untyped future.
Future*[T] = ref object of FutureBase ## Typed future.
value: T ## Stored value
FutureVar*[T] = distinct Future[T]
proc newFuture*[T](): Future[T] =
new(result)
proc newFutureVar*[T](): FutureVar[T] =
result = FutureVar[T](newFuture[T]())
proc mget*[T](future: FutureVar[T]): var T =
Future[T](future).value
proc reset*[T](future: FutureVar[T]) =
echo "Called!"
when true:
var foo = newFutureVar[string]()
foo.mget() = ""
foo.mget.add("Foobar")
foo.reset()

View file

@ -112,6 +112,7 @@ General FAQ
- jEdit: https://github.com/exhu/nimrod-misc/tree/master/jedit
- TextMate: Available in bundle installer (`Repository <https://github.com/textmate/nim.tmbundle>`_)
- Sublime Text: Available via Package Control (`Repository <https://github.com/Varriount/NimLime>`_)
- LiClipse: http://www.liclipse.com/ (Eclipse based plugin)
.. container:: standout