This commit is contained in:
Araq
2014-11-17 08:28:24 +01:00
parent fd532b6dab
commit 729e048a32
6 changed files with 38 additions and 5 deletions

View File

@@ -894,8 +894,15 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
put(g, tkParLe, "(")
for i in countup(0, sonsLen(n) - 1):
if i > 0: put(g, tkOpr, "|")
gsub(g, n.sons[i], c)
put(g, tkParRi, ")")
if n.sons[i].kind == nkSym:
let s = n[i].sym
if s.owner != nil:
put g, tkSymbol, n[i].sym.owner.name.s
put g, tkOpr, "."
put g, tkSymbol, n[i].sym.name.s
else:
gsub(g, n.sons[i], c)
put(g, tkParRi, if n.kind == nkOpenSymChoice: "|...)" else: ")")
of nkPar, nkClosure:
put(g, tkParLe, "(")
gcomma(g, n, c)

View File

@@ -166,7 +166,7 @@ proc semGenericStmt(c: PContext, n: PNode,
var first = 0
var isDefinedMagic = false
if s != nil:
if s != nil:
incl(s.flags, sfUsed)
isDefinedMagic = s.magic in {mDefined, mDefinedInScope, mCompiles}
let scOption = if s.name.id in ctx: scForceOpen else: scOpen

View File

@@ -63,7 +63,8 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule): PNode =
else:
# semantic checking requires a type; ``fitNode`` deals with it
# appropriately
let kind = if r == scClosed: nkClosedSymChoice else: nkOpenSymChoice
let kind = if r == scClosed or n.kind == nkDotExpr: nkClosedSymChoice
else: nkOpenSymChoice
result = newNodeIT(kind, n.info, newTypeS(tyNone, c))
a = initOverloadIter(o, c, n)
while a != nil:

View File

@@ -23,7 +23,7 @@ type
csEmpty, csMatch, csNoMatch
CandidateErrors* = seq[PSym]
TCandidate* {.final.} = object
TCandidate* = object
c*: PContext
exactMatches*: int # also misused to prefer iters over procs
genericMatches: int # also misused to prefer constraints

View File

@@ -13,6 +13,7 @@ pragmas:
3) Locks and routines can be annotated with `lock levels`:idx: to prevent
deadlocks at compile time.
Guards and the locks section
----------------------------

View File

@@ -0,0 +1,24 @@
discard """
output: '''10'''
"""
# bug #940
type
Foo* = ref object
b*: int
proc new*(this: var Foo) =
assert this != nil
this.b = 10
proc new*(T: typedesc[Foo]): Foo =
system.new(result)
twrongopensymchoice.new(result)
proc main =
var f = Foo.new()
echo f.b
when isMainModule:
main()