This commit is contained in:
Araq 2015-09-13 23:26:44 +02:00
commit 14354b436f
5 changed files with 40 additions and 13 deletions

View file

@ -430,17 +430,10 @@ proc evalOp(m: TMagic, n, a, b, c: PNode): PNode =
of mCompileOptionArg: of mCompileOptionArg:
result = newIntNodeT(ord( result = newIntNodeT(ord(
testCompileOptionArg(getStr(a), getStr(b), n.info)), n) testCompileOptionArg(getStr(a), getStr(b), n.info)), n)
of mNewString, mNewStringOfCap,
mExit, mInc, ast.mDec, mEcho, mSwap, mAppendStrCh,
mAppendStrStr, mAppendSeqElem, mSetLengthStr, mSetLengthSeq,
mParseExprToAst, mParseStmtToAst, mExpandToAst, mTypeTrait, mDotDot,
mNLen..mNError, mEqRef, mSlurp, mStaticExec, mNGenSym, mSpawn,
mParallel, mPlugin, mGetTypeInfo, mTypeOf:
discard
of mEqProc: of mEqProc:
result = newIntNodeT(ord( result = newIntNodeT(ord(
exprStructuralEquivalent(a, b, strictSymEquality=true)), n) exprStructuralEquivalent(a, b, strictSymEquality=true)), n)
else: internalError(a.info, "evalOp(" & $m & ')') else: discard
proc getConstIfExpr(c: PSym, n: PNode): PNode = proc getConstIfExpr(c: PSym, n: PNode): PNode =
result = nil result = nil

View file

@ -265,9 +265,6 @@ proc describeArgs*(c: PContext, n: PNode, startIdx = 1;
proc typeRel*(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation proc typeRel*(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation
proc concreteType(c: TCandidate, t: PType): PType = proc concreteType(c: TCandidate, t: PType): PType =
# currently `[]=` is defined rather sloppily in system.nim, so we have
# a special type matching rule for it:
if c.calleeSym != nil and c.calleeSym.magic == mArrPut: return t
case t.kind case t.kind
of tyArrayConstr: of tyArrayConstr:
# make it an array # make it an array
@ -1694,7 +1691,7 @@ proc partialMatch*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
matchesAux(c, n, nOrig, m, marker) matchesAux(c, n, nOrig, m, marker)
proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) = proc matches*(c: PContext, n, nOrig: PNode, m: var TCandidate) =
if m.calleeSym != nil and m.calleeSym.magic == mArrGet: if m.calleeSym != nil and m.calleeSym.magic in {mArrGet, mArrPut}:
m.state = csMatch m.state = csMatch
m.call = n m.call = n
return return

View file

@ -0,0 +1,17 @@
import tables
type
UUIDObject* = ref object
uuid: string
Registry*[T] = ref object
objects: Table[string, T]
proc newRegistry*[T](): Registry[T] =
result = Registry[T]()
result.objects = initTable[string, T](128)
proc register*[T](self: Registry[T], obj: T) =
self.objects[obj.uuid] = obj

View file

@ -0,0 +1,20 @@
discard """
output: "317"
"""
# bug #2599
import mbind_bracket
# also test that `[]` can be passed now as a first class construct:
template takeBracket(x, a, i: untyped) =
echo x(a, i)
var a: array[10, int]
a[8] = 317
takeBracket(`[]`, a, 8)
let reg = newRegistry[UUIDObject]()
reg.register(UUIDObject())

View file

@ -3,7 +3,7 @@ discard """
""" """
type type
TThreadFuncArgs[T] = object of TObject TThreadFuncArgs[T] = object of RootObj
a: proc(): T {.thread.} a: proc(): T {.thread.}
b: proc(val: T) {.thread.} b: proc(val: T) {.thread.}