diff options
author | Araq <rumpf_a@web.de> | 2015-09-12 20:42:27 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-09-12 20:42:27 +0200 |
commit | 03d8467942451e822f0fc02c865a6ac3113888fb (patch) | |
tree | 9c836410385941118047a3eca3824627d5fec62a /compiler | |
parent | 8ef66b973d86a75c8dfa4c6761d322d94c54efad (diff) | |
parent | c27019f4d9db52f6e3922ac3d222d2b6e3b73fb2 (diff) | |
download | Nim-03d8467942451e822f0fc02c865a6ac3113888fb.tar.gz |
Merge branch 'devel' into fix_bracket_expr
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/seminst.nim | 3 | ||||
-rw-r--r-- | compiler/semtempl.nim | 11 | ||||
-rw-r--r-- | compiler/vm.nim | 2 |
3 files changed, 16 insertions, 0 deletions
diff --git a/compiler/seminst.nim b/compiler/seminst.nim index 370990326..42a39d0df 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -221,6 +221,8 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable, # NOTE: for access of private fields within generics from a different module # we set the friend module: c.friendModules.add(getModule(fn)) + let oldInTypeClass = c.inTypeClass + c.inTypeClass = 0 let oldScope = c.currentScope while not isTopLevel(c): c.currentScope = c.currentScope.parent result = copySym(fn, false) @@ -269,4 +271,5 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable, c.currentScope = oldScope discard c.friendModules.pop() dec(c.instCounter) + c.inTypeClass = oldInTypeClass if result.kind == skMethod: finishMethod(c, result) diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim index 642fcb527..fc1af7246 100644 --- a/compiler/semtempl.nim +++ b/compiler/semtempl.nim @@ -632,6 +632,11 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode = localError(n.info, errInvalidExpression) result = n + proc stupidStmtListExpr(n: PNode): bool = + for i in 0 .. n.len-2: + if n[i].kind notin {nkEmpty, nkCommentStmt}: return false + result = true + result = n case n.kind of nkIdent: @@ -657,6 +662,12 @@ proc semPatternBody(c: var TemplCtx, n: PNode): PNode = localError(n.info, errInvalidExpression) else: localError(n.info, errInvalidExpression) + of nkStmtList, nkStmtListExpr: + if stupidStmtListExpr(n): + result = semPatternBody(c, n.lastSon) + else: + for i in countup(0, sonsLen(n) - 1): + result.sons[i] = semPatternBody(c, n.sons[i]) of nkCallKinds: let s = qualifiedLookUp(c.c, n.sons[0], {}) if s != nil: diff --git a/compiler/vm.nim b/compiler/vm.nim index 05d00c19f..0db287c6a 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -1461,6 +1461,8 @@ proc evalConstExprAux(module, prc: PSym, n: PNode, mode: TEvalMode): PNode = let n = transformExpr(module, n) setupGlobalCtx(module) var c = globalCtx + let oldMode = c.mode + defer: c.mode = oldMode c.mode = mode let start = genExpr(c, n, requiresValue = mode!=emStaticStmt) if c.code[start].opcode == opcEof: return emptyNode |