summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/renderer.nim11
-rw-r--r--compiler/semgnrc.nim2
-rw-r--r--compiler/semtempl.nim3
-rw-r--r--compiler/sigmatch.nim2
-rw-r--r--doc/manual/locking.txt1
-rw-r--r--tests/template/twrongopensymchoice.nim24
6 files changed, 38 insertions, 5 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index a4469acda..b0d328f9e 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -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)
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index 6c218fa0c..07e7a5136 100644
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -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
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index 0a647a65d..38b0536db 100644
--- a/compiler/semtempl.nim
+++ b/compiler/semtempl.nim
@@ -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:
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 4a3773ed8..e44cd7049 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -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
diff --git a/doc/manual/locking.txt b/doc/manual/locking.txt
index 1a6d2783c..864eeccb5 100644
--- a/doc/manual/locking.txt
+++ b/doc/manual/locking.txt
@@ -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
 ----------------------------
 
diff --git a/tests/template/twrongopensymchoice.nim b/tests/template/twrongopensymchoice.nim
new file mode 100644
index 000000000..5a02a813c
--- /dev/null
+++ b/tests/template/twrongopensymchoice.nim
@@ -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()