mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 06:45:27 +00:00
fixes #940
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
----------------------------
|
||||
|
||||
|
||||
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()
|
||||
Reference in New Issue
Block a user