summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/msgs.nim5
-rw-r--r--compiler/semdata.nim20
-rw-r--r--compiler/semexprs.nim2
-rw-r--r--compiler/semmagic.nim8
-rw-r--r--compiler/semobjconstr.nim13
-rw-r--r--compiler/semstmts.nim8
6 files changed, 23 insertions, 33 deletions
diff --git a/compiler/msgs.nim b/compiler/msgs.nim
index 30421fe6a..89949ef17 100644
--- a/compiler/msgs.nim
+++ b/compiler/msgs.nim
@@ -14,7 +14,7 @@ import std/private/miscdollars
 import strutils2
 
 type InstantiationInfo* = typeof(instantiationInfo())
-template instLoc(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)
+template instLoc*(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)
 
 template toStdOrrKind(stdOrr): untyped =
   if stdOrr == stdout: stdOrrStdout else: stdOrrStderr
@@ -600,9 +600,6 @@ template localError*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg = "")
 template localError*(conf: ConfigRef; info: TLineInfo, arg: string) =
   liMessage(conf, info, errGenerated, arg, doNothing, instLoc())
 
-template localError*(conf: ConfigRef; info: TLineInfo, format: string, params: openArray[string]) =
-  liMessage(conf, info, errGenerated, format % params, doNothing, instLoc())
-
 template message*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg = "") =
   liMessage(conf, info, msg, arg, doNothing, instLoc())
 
diff --git a/compiler/semdata.nim b/compiler/semdata.nim
index 354d4587d..95278893a 100644
--- a/compiler/semdata.nim
+++ b/compiler/semdata.nim
@@ -501,18 +501,14 @@ proc errorNode*(c: PContext, n: PNode): PNode =
   result = newNodeI(nkEmpty, n.info)
   result.typ = errorType(c)
 
-proc localErrorNode*(c: PContext, n: PNode, info: TLineInfo, msg: TMsgKind, arg: string): PNode =
-  localError(c.config, info, msg, arg)
-  result = errorNode(c, n)
-
-proc localErrorNode*(c: PContext, n: PNode, info: TLineInfo, arg: string): PNode =
-  localErrorNode(c, n, info, errGenerated, arg)
-
-proc localErrorNode*(c: PContext, n: PNode, msg: TMsgKind, arg: string): PNode =
-  localErrorNode(c, n, n.info, msg, arg)
-
-proc localErrorNode*(c: PContext, n: PNode, arg: string): PNode =
-  localErrorNode(c, n, n.info, errGenerated, arg)
+template localErrorNode*(c: PContext, n: PNode, arg: string, info: TLineInfo, kind: TMsgKind = errGenerated): PNode =
+  liMessage(c.config, info, kind, arg, doNothing, instLoc())
+  errorNode(c, n)
+
+template localErrorNode*(c: PContext, n: PNode, arg: string, kind: TMsgKind = errGenerated): PNode =
+  let n2 = n
+  liMessage(c.config, n2.info, kind, arg, doNothing, instLoc())
+  errorNode(c, n2)
 
 proc fillTypeS*(dest: PType, kind: TTypeKind, c: PContext) =
   dest.kind = kind
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 353831736..defceb291 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -2620,7 +2620,7 @@ proc semTupleConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
     # check if either everything or nothing is tyTypeDesc
     for i in 1..<tupexp.len:
       if isTupleType != (tupexp[i].typ.kind == tyTypeDesc):
-        return localErrorNode(c, n, tupexp[i].info, "Mixing types and values in tuples is not allowed.")
+        return localErrorNode(c, n, "Mixing types and values in tuples is not allowed.", tupexp[i].info)
   if isTupleType: # expressions as ``(int, string)`` are reinterpret as type expressions
     result = n
     var typ = semTypeNode(c, n, nil).skipTypes({tyTypeDesc})
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index e4e007678..69a69375e 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -229,12 +229,12 @@ proc semBindSym(c: PContext, n: PNode): PNode =
 
   let sl = semConstExpr(c, n[1])
   if sl.kind notin {nkStrLit, nkRStrLit, nkTripleStrLit}:
-    return localErrorNode(c, n, n[1].info, errStringLiteralExpected)
+    return localErrorNode(c, n, errStringLiteralExpected, n[1].info)
 
   let isMixin = semConstExpr(c, n[2])
   if isMixin.kind != nkIntLit or isMixin.intVal < 0 or
       isMixin.intVal > high(TSymChoiceRule).int:
-    return localErrorNode(c, n, n[2].info, errConstExprExpected)
+    return localErrorNode(c, n, errConstExprExpected, n[2].info)
 
   let id = newIdentNode(getIdent(c.cache, sl.strVal), n.info)
   let s = qualifiedLookUp(c, id, {checkUndeclared})
@@ -251,10 +251,10 @@ proc semBindSym(c: PContext, n: PNode): PNode =
 
 proc opBindSym(c: PContext, scope: PScope, n: PNode, isMixin: int, info: PNode): PNode =
   if n.kind notin {nkStrLit, nkRStrLit, nkTripleStrLit, nkIdent}:
-    return localErrorNode(c, n, info.info, errStringOrIdentNodeExpected)
+    return localErrorNode(c, n, errStringOrIdentNodeExpected, info.info)
 
   if isMixin < 0 or isMixin > high(TSymChoiceRule).int:
-    return localErrorNode(c, n, info.info, errConstExprExpected)
+    return localErrorNode(c, n, errConstExprExpected, info.info)
 
   let id = if n.kind == nkIdent: n
     else: newIdentNode(getIdent(c.cache, n.strVal), info.info)
diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim
index 63b4b9a75..01d5a8b28 100644
--- a/compiler/semobjconstr.nim
+++ b/compiler/semobjconstr.nim
@@ -210,7 +210,7 @@ proc semConstructFields(c: PContext, n: PNode,
         localError(c.config, constrCtx.initExpr.info,
           "a case selecting discriminator '$1' with value '$2' " &
           "appears in the object construction, but the field(s) $3 " &
-          "are in conflict with this value.",
+          "are in conflict with this value." %
           [discriminator.sym.name.s, discriminatorVal.renderTree, fields])
 
       template valuesInConflictError(valsDiff) =
@@ -365,11 +365,10 @@ proc defaultConstructionError(c: PContext, t: PType, info: TLineInfo) =
     assert constrCtx.missingFields.len > 0
     localError(c.config, info,
       "The $1 type doesn't have a default value. The following fields must " &
-      "be initialized: $2.",
-      [typeToString(t), listSymbolNames(constrCtx.missingFields)])
+      "be initialized: $2." % [typeToString(t), listSymbolNames(constrCtx.missingFields)])
   elif objType.kind == tyDistinct:
     localError(c.config, info,
-      "The $1 distinct type doesn't have a default value.", [typeToString(t)])
+      "The $1 distinct type doesn't have a default value." % typeToString(t))
   else:
     assert false, "Must not enter here."
 
@@ -379,7 +378,7 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
   for child in n: result.add child
 
   if t == nil:
-    return localErrorNode(c, result, errGenerated, "object constructor needs an object type")
+    return localErrorNode(c, result, "object constructor needs an object type")
 
   t = skipTypes(t, {tyGenericInst, tyAlias, tySink, tyOwned})
   if t.kind == tyRef:
@@ -390,7 +389,7 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
       # multiple times as long as they don't have closures.
       result.typ.flags.incl tfHasOwned
   if t.kind != tyObject:
-    return localErrorNode(c, result, errGenerated, "object constructor needs an object type")
+    return localErrorNode(c, result, "object constructor needs an object type")
 
   # Check if the object is fully initialized by recursively testing each
   # field (if this is a case object, initialized fields in two different
@@ -404,7 +403,7 @@ proc semObjConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
   if constrCtx.missingFields.len > 0:
     hasError = true
     localError(c.config, result.info,
-      "The $1 type requires the following fields to be initialized: $2.",
+      "The $1 type requires the following fields to be initialized: $2." %
       [t.sym.name.s, listSymbolNames(constrCtx.missingFields)])
 
   # Since we were traversing the object fields, it's possible that
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index a10047187..22e4295fa 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -725,7 +725,7 @@ proc semForVars(c: PContext, n: PNode; flags: TExprFlags): PNode =
     if n.len == 3:
       if n[0].kind == nkVarTuple:
         if n[0].len-1 != iterAfterVarLent.len:
-          return localErrorNode(c, n, n[0].info, errWrongNumberOfVariables)
+          return localErrorNode(c, n, errWrongNumberOfVariables, n[0].info)
 
         for i in 0..<n[0].len-1:
           var v = symForVar(c, n[0][i])
@@ -1024,8 +1024,7 @@ proc semRaise(c: PContext, n: PNode): PNode =
       if typ.kind != tyRef:
         localError(c.config, n.info, errExprCannotBeRaised)
       if typ.len > 0 and not isException(typ.lastSon):
-        localError(c.config, n.info, "raised object of type $1 does not inherit from Exception",
-                          [typeToString(typ)])
+        localError(c.config, n.info, "raised object of type $1 does not inherit from Exception" % typeToString(typ))
 
 proc addGenericParamListToScope(c: PContext, n: PNode) =
   if n.kind != nkGenericParams: illFormedAst(n, c.config)
@@ -2201,8 +2200,7 @@ proc inferConceptStaticParam(c: PContext, inferred, n: PNode) =
   if not sameType(res.typ, typ.base):
     localError(c.config, n.info,
       "cannot infer the concept parameter '%s', due to a type mismatch. " &
-      "attempt to equate '%s' and '%s'.",
-      [inferred.renderTree, $res.typ, $typ.base])
+      "attempt to equate '%s' and '%s'." % [inferred.renderTree, $res.typ, $typ.base])
   typ.n = res
 
 proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode =