Merge branch 'devel' into fix_bracket_expr
This commit is contained in:
commit
03d8467942
13 changed files with 200 additions and 55 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue