fixes #940
This commit is contained in:
parent
fd532b6dab
commit
729e048a32
6 changed files with 38 additions and 5 deletions
|
|
@ -894,8 +894,15 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
|
||||||
put(g, tkParLe, "(")
|
put(g, tkParLe, "(")
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
if i > 0: put(g, tkOpr, "|")
|
if i > 0: put(g, tkOpr, "|")
|
||||||
gsub(g, n.sons[i], c)
|
if n.sons[i].kind == nkSym:
|
||||||
put(g, tkParRi, ")")
|
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:
|
of nkPar, nkClosure:
|
||||||
put(g, tkParLe, "(")
|
put(g, tkParLe, "(")
|
||||||
gcomma(g, n, c)
|
gcomma(g, n, c)
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
|
|
||||||
var first = 0
|
var first = 0
|
||||||
var isDefinedMagic = false
|
var isDefinedMagic = false
|
||||||
if s != nil:
|
if s != nil:
|
||||||
incl(s.flags, sfUsed)
|
incl(s.flags, sfUsed)
|
||||||
isDefinedMagic = s.magic in {mDefined, mDefinedInScope, mCompiles}
|
isDefinedMagic = s.magic in {mDefined, mDefinedInScope, mCompiles}
|
||||||
let scOption = if s.name.id in ctx: scForceOpen else: scOpen
|
let scOption = if s.name.id in ctx: scForceOpen else: scOpen
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,8 @@ proc symChoice(c: PContext, n: PNode, s: PSym, r: TSymChoiceRule): PNode =
|
||||||
else:
|
else:
|
||||||
# semantic checking requires a type; ``fitNode`` deals with it
|
# semantic checking requires a type; ``fitNode`` deals with it
|
||||||
# appropriately
|
# 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))
|
result = newNodeIT(kind, n.info, newTypeS(tyNone, c))
|
||||||
a = initOverloadIter(o, c, n)
|
a = initOverloadIter(o, c, n)
|
||||||
while a != nil:
|
while a != nil:
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ type
|
||||||
csEmpty, csMatch, csNoMatch
|
csEmpty, csMatch, csNoMatch
|
||||||
|
|
||||||
CandidateErrors* = seq[PSym]
|
CandidateErrors* = seq[PSym]
|
||||||
TCandidate* {.final.} = object
|
TCandidate* = object
|
||||||
c*: PContext
|
c*: PContext
|
||||||
exactMatches*: int # also misused to prefer iters over procs
|
exactMatches*: int # also misused to prefer iters over procs
|
||||||
genericMatches: int # also misused to prefer constraints
|
genericMatches: int # also misused to prefer constraints
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ pragmas:
|
||||||
3) Locks and routines can be annotated with `lock levels`:idx: to prevent
|
3) Locks and routines can be annotated with `lock levels`:idx: to prevent
|
||||||
deadlocks at compile time.
|
deadlocks at compile time.
|
||||||
|
|
||||||
|
|
||||||
Guards and the locks section
|
Guards and the locks section
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
|
|
||||||
24
tests/template/twrongopensymchoice.nim
Normal file
24
tests/template/twrongopensymchoice.nim
Normal 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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue