From 0e439ce36738170bbc1097fcedfed5def7514a31 Mon Sep 17 00:00:00 2001 From: Araq Date: Sun, 26 Oct 2014 22:48:54 +0100 Subject: [PATCH] implements #78 --- compiler/semcall.nim | 3 +-- compiler/types.nim | 4 ++-- csources | 1 - tests/clearmsg/mb.nim | 2 ++ tests/clearmsg/mc.nim | 3 +++ tests/clearmsg/ta.nim | 12 ++++++++++++ 6 files changed, 20 insertions(+), 5 deletions(-) delete mode 160000 csources create mode 100644 tests/clearmsg/mb.nim create mode 100644 tests/clearmsg/mc.nim create mode 100644 tests/clearmsg/ta.nim diff --git a/compiler/semcall.nim b/compiler/semcall.nim index a4490b782b..d3720b0ab7 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -94,7 +94,7 @@ proc notFoundError*(c: PContext, n: PNode, errors: CandidateErrors) = var prefer = preferName for err in errors: - var errProto = "(" + var errProto = "" let n = err.typ.n for i in countup(1, n.len - 1): var p = n.sons[i] @@ -102,7 +102,6 @@ proc notFoundError*(c: PContext, n: PNode, errors: CandidateErrors) = add(errProto, typeToString(p.sym.typ, prefer)) if i != n.len-1: add(errProto, ", ") # else: ignore internal error as we're already in error handling mode - add(errProto, ')') if errProto == proto: prefer = preferModuleInfo break diff --git a/compiler/types.nim b/compiler/types.nim index e037621556..87f2e1a596 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -419,10 +419,10 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = sfAnon notin t.sym.flags: if t.kind == tyInt and isIntLit(t): return t.sym.name.s & " literal(" & $t.n.intVal & ")" - if prefer == preferName: + if prefer == preferName or t.sym.owner.isNil: return t.sym.name.s else: - return t.sym.skipGenericOwner.name.s & '.' & t.sym.name.s + return t.sym.owner.name.s & '.' & t.sym.name.s case t.kind of tyInt: if not isIntLit(t) or prefer == preferExported: diff --git a/csources b/csources deleted file mode 160000 index b0bcf88e26..0000000000 --- a/csources +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b0bcf88e26730b23d22e2663adf1babb05bd5a71 diff --git a/tests/clearmsg/mb.nim b/tests/clearmsg/mb.nim new file mode 100644 index 0000000000..2d21e2396d --- /dev/null +++ b/tests/clearmsg/mb.nim @@ -0,0 +1,2 @@ +type + typ* = distinct string diff --git a/tests/clearmsg/mc.nim b/tests/clearmsg/mc.nim new file mode 100644 index 0000000000..79d7431df7 --- /dev/null +++ b/tests/clearmsg/mc.nim @@ -0,0 +1,3 @@ + +type + typ* = distinct int diff --git a/tests/clearmsg/ta.nim b/tests/clearmsg/ta.nim new file mode 100644 index 0000000000..b21522d127 --- /dev/null +++ b/tests/clearmsg/ta.nim @@ -0,0 +1,12 @@ +discard """ + errormsg: 'type mismatch: got (mc.typ)' + line: 12 +""" + +import mb, mc + +proc test(testing: mb.typ) = + discard + +var s: mc.typ +test(s)