summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-01-13 15:47:17 +0100
committerGitHub <noreply@github.com>2020-01-13 15:47:17 +0100
commiteadd1ba9ed38a1c8f48005443f60499b1f0200e3 (patch)
tree541eff4cc2be6b501faa08ac8ac724c83dd84bf0 /compiler/semstmts.nim
parentabea80376a113fb218c22b6474727c279e694cd3 (diff)
downloadNim-eadd1ba9ed38a1c8f48005443f60499b1f0200e3.tar.gz
fixes #13112 (#13127)
* improve line error information

* fixes #13112
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index f21f5122c..475ec32a4 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1603,6 +1603,15 @@ proc prevDestructor(c: PContext; prevOp: PSym; obj: PType; info: TLineInfo) =
     msg.add "; previous declaration was here: " & (c.config $ prevOp.info)
   localError(c.config, info, errGenerated, msg)
 
+proc whereToBindTypeHook(c: PContext; t: PType): PType =
+  result = t
+  while true:
+    if result.kind in {tyGenericBody, tyGenericInst}: result = result.lastSon
+    elif result.kind == tyGenericInvocation: result = result[0]
+    else: break
+  if result.kind in {tyObject, tyDistinct, tySequence, tyString}:
+    result = canonType(c, result)
+
 proc bindTypeHook(c: PContext; s: PSym; n: PNode; op: TTypeAttachedOp) =
   let t = s.typ
   var noError = false