diff options
author | Araq <rumpf_a@web.de> | 2013-03-11 08:42:35 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2013-03-11 08:42:35 +0100 |
commit | 78b27ed7fa121d2cb032fa1b74ae434034bf8e23 (patch) | |
tree | 365c6446a5ab04fa7711368b5079c4d8a3204c1f /compiler | |
parent | 5ac5bedc66c94a781c4a23fa6d0407c012276aa7 (diff) | |
download | Nim-78b27ed7fa121d2cb032fa1b74ae434034bf8e23.tar.gz |
bugfix: 'indexOf' for tuple fields works
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/semfold.nim | 11 | ||||
-rwxr-xr-x | compiler/semgnrc.nim | 5 |
2 files changed, 9 insertions, 7 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim index e26700e27..d304ddd3c 100755 --- a/compiler/semfold.nim +++ b/compiler/semfold.nim @@ -490,7 +490,7 @@ proc getArrayConstr(m: PSym, n: PNode): PNode = proc foldArrayAccess(m: PSym, n: PNode): PNode = var x = getConstExpr(m, n.sons[0]) - if x == nil: return + if x == nil or x.typ.skipTypes({tyGenericInst}).kind == tyTypeDesc: return var y = getConstExpr(m, n.sons[1]) if y == nil: return @@ -541,7 +541,12 @@ proc foldConStrStr(m: PSym, n: PNode): PNode = let a = getConstExpr(m, n.sons[i]) if a == nil: return nil result.strVal.add(getStrOrChar(a)) - + +proc newSymNodeTypeDesc*(s: PSym; info: TLineInfo): PNode = + result = newSymNode(s, info) + result.typ = newType(tyTypeDesc, s.owner) + result.typ.addSonSkipIntLit(s.typ) + proc getConstExpr(m: PSym, n: PNode): PNode = result = nil case n.kind @@ -569,6 +574,8 @@ proc getConstExpr(m: PSym, n: PNode): PNode = if sfFakeConst notin s.flags: result = copyTree(s.ast) elif s.kind in {skProc, skMethod}: # BUGFIX result = n + elif s.kind in {skType, skGenericParam}: + result = newSymNodeTypeDesc(s, n.info) of nkCharLit..nkNilLit: result = copyNode(n) of nkIfExpr: diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index 2e1eccda2..8c3cef027 100755 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -31,11 +31,6 @@ proc getIdentNode(n: PNode): PNode = illFormedAst(n) result = n -proc newSymNodeTypeDesc(s: PSym; info: TLineInfo): PNode = - result = newSymNode(s, info) - result.typ = newType(tyTypeDesc, s.owner) - result.typ.addSonSkipIntLit(s.typ) - proc semGenericStmt(c: PContext, n: PNode, flags: TSemGenericFlags, ctx: var TIntSet): PNode proc semGenericStmtScope(c: PContext, n: PNode, |