summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-11-04 22:40:51 +0100
committerAraq <rumpf_a@web.de>2012-11-04 22:40:51 +0100
commit42c8fd1fe2e8a045741c18cd02f9410cb7a990f8 (patch)
tree4f3029e0e4c6adfae8803f386765a71942b2e3ca
parent6dd2c2d7670b11aa2155f41e1309dad011456140 (diff)
downloadNim-42c8fd1fe2e8a045741c18cd02f9410cb7a990f8.tar.gz
bugfixes for exception tracking
-rw-r--r--compiler/sempass2.nim11
-rw-r--r--tests/reject/teffects1.nim2
2 files changed, 9 insertions, 4 deletions
diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim
index 1811beb2d..86c7929d9 100644
--- a/compiler/sempass2.nim
+++ b/compiler/sempass2.nim
@@ -123,7 +123,8 @@ proc catches(tracked: PEffects, e: PType) =
   setLen(tracked.exc.sons, L)
   
 proc catchesAll(tracked: PEffects) =
-  setLen(tracked.exc.sons, tracked.bottom)
+  if not isNil(tracked.exc.sons):
+    setLen(tracked.exc.sons, tracked.bottom)
 
 proc track(tracked: PEffects, n: PNode)
 proc trackTryStmt(tracked: PEffects, n: PNode) =
@@ -156,7 +157,9 @@ proc trackPragmaStmt(tracked: PEffects, n: PNode) =
     var it = n.sons[i]
     if whichPragma(it) == wEffects:
       # list the computed effects up to here:
+      pushInfoContext(n.info)
       listEffects(tracked)
+      popInfoContext()
 
 proc raisesSpec*(n: PNode): PNode =
   for i in countup(0, sonsLen(n) - 1):
@@ -253,9 +256,10 @@ proc checkRaisesSpec(spec, real: PNode) =
           used.incl(s)
           break search
       # XXX call graph analysis would be nice here!
-      localError(spec.info, errInstantiationFrom)
+      pushInfoContext(spec.info)
       localError(r.info, errGenerated, "can raise an unlisted exception: " &
         typeToString(r.typ))
+      popInfoContext()
   # hint about unnecessarily listed exception types:
   for s in 0 .. <spec.len:
     if not used.contains(s):
@@ -274,9 +278,10 @@ proc checkMethodEffects*(disp, branch: PSym) =
         for s in 0 .. <spec.len:
           if inheritanceDiff(r.excType, spec[s].typ) <= 0:
             break search
-        localError(branch.info, errInstantiationFrom)
+        pushInfoContext(branch.info)
         localError(r.info, errGenerated, "can raise an unlisted exception: " &
           typeToString(r.typ))
+        popInfoContext()
 
 proc setEffectsForProcType*(t: PType, n: PNode) =
   var effects = t.n.sons[0]
diff --git a/tests/reject/teffects1.nim b/tests/reject/teffects1.nim
index a6702df83..cb5e43b26 100644
--- a/tests/reject/teffects1.nim
+++ b/tests/reject/teffects1.nim
@@ -1,5 +1,5 @@
 discard """
-  line: 16
+  line: 15
   errormsg: "instantiation from here"
 """