summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-09-03 10:50:39 +0200
committerAraq <rumpf_a@web.de>2018-09-03 10:50:39 +0200
commitb3c3a463177ebb0aeb6e9eb11788230ab91c3f08 (patch)
treeeb1d775032ef254998d10e40686d06f8158e44b6 /compiler
parent7cea0c1765177abaa20902fddfbd3ee50992210f (diff)
downloadNim-b3c3a463177ebb0aeb6e9eb11788230ab91c3f08.tar.gz
fixes #5745
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ast.nim12
-rw-r--r--compiler/lineinfos.nim3
-rw-r--r--compiler/msgs.nim3
3 files changed, 11 insertions, 7 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 6591105d4..001d96060 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -1594,15 +1594,17 @@ proc getInt*(a: PNode): BiggestInt =
   case a.kind
   of nkCharLit..nkUInt64Lit: result = a.intVal
   else:
+    raiseRecoverableError("cannot extract number from invalid AST node")
     #internalError(a.info, "getInt")
-    doAssert false, "getInt"
+    #doAssert false, "getInt"
     #result = 0
 
 proc getFloat*(a: PNode): BiggestFloat =
   case a.kind
   of nkFloatLiterals: result = a.floatVal
   else:
-    doAssert false, "getFloat"
+    raiseRecoverableError("cannot extract number from invalid AST node")
+    #doAssert false, "getFloat"
     #internalError(a.info, "getFloat")
     #result = 0.0
 
@@ -1616,7 +1618,8 @@ proc getStr*(a: PNode): string =
     else:
       result = nil
   else:
-    doAssert false, "getStr"
+    raiseRecoverableError("cannot extract string from invalid AST node")
+    #doAssert false, "getStr"
     #internalError(a.info, "getStr")
     #result = ""
 
@@ -1625,7 +1628,8 @@ proc getStrOrChar*(a: PNode): string =
   of nkStrLit..nkTripleStrLit: result = a.strVal
   of nkCharLit..nkUInt64Lit: result = $chr(int(a.intVal))
   else:
-    doAssert false, "getStrOrChar"
+    raiseRecoverableError("cannot extract string from invalid AST node")
+    #doAssert false, "getStrOrChar"
     #internalError(a.info, "getStrOrChar")
     #result = ""
 
diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim
index c5a641713..41f3806d4 100644
--- a/compiler/lineinfos.nim
+++ b/compiler/lineinfos.nim
@@ -223,6 +223,9 @@ type
 
 proc `==`*(a, b: FileIndex): bool {.borrow.}
 
+proc raiseRecoverableError*(msg: string) {.noinline, noreturn.} =
+  raise newException(ERecoverableError, msg)
+
 const
   InvalidFileIDX* = FileIndex(-1)
 
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index 47ab878f1..b7b7c8474 100644
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -102,9 +102,6 @@ proc newLineInfo*(fileInfoIdx: FileIndex, line, col: int): TLineInfo =
 proc newLineInfo*(conf: ConfigRef; filename: string, line, col: int): TLineInfo {.inline.} =
   result = newLineInfo(fileInfoIdx(conf, filename), line, col)
 
-proc raiseRecoverableError*(msg: string) {.noinline, noreturn.} =
-  raise newException(ERecoverableError, msg)
-
 
 proc concat(strings: openarray[string]): string =
   var totalLen = 0