From 86b7de224a0f250ee05f49ec6b5b675a0de82f69 Mon Sep 17 00:00:00 2001 From: Julian Fondren Date: Sun, 28 Apr 2019 01:40:42 -0500 Subject: [PATCH 1/6] provide more useful ambiguous-identifier error output --- compiler/lookups.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 8bc2634854..926458080d 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -255,9 +255,9 @@ proc errorUseQualifier*(c: PContext; info: TLineInfo; s: PSym) = var candidate = initIdentIter(ti, c.importTable.symbols, s.name) var i = 0 while candidate != nil: - if i == 0: err.add " --use " - else: err.add " or " - err.add candidate.owner.name.s & "." & candidate.name.s + if i == 0: err.add " --use one of the following:\n" + else: err.add "\n" + err.add typeToString(candidate.typ) candidate = nextIdentIter(ti, c.importTable.symbols) inc i localError(c.config, info, errGenerated, err) From d85de3cd57defdf51f031a368976c90b50f6b006 Mon Sep 17 00:00:00 2001 From: Julian Fondren Date: Sun, 28 Apr 2019 01:51:56 -0500 Subject: [PATCH 2/6] re-include module in ambiguous identifier output --- compiler/lookups.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 926458080d..51b453ca48 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -257,7 +257,7 @@ proc errorUseQualifier*(c: PContext; info: TLineInfo; s: PSym) = while candidate != nil: if i == 0: err.add " --use one of the following:\n" else: err.add "\n" - err.add typeToString(candidate.typ) + err.add candidate.owner.name.s & "." & typeToString(candidate.typ) candidate = nextIdentIter(ti, c.importTable.symbols) inc i localError(c.config, info, errGenerated, err) From d8e0d6801bfda2f03c83f26f2a1d9901ff7485e4 Mon Sep 17 00:00:00 2001 From: Julian Fondren Date: Sun, 28 Apr 2019 02:00:06 -0500 Subject: [PATCH 3/6] re-include ambiguous identifier in ambiguous identifier output --- compiler/lookups.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 51b453ca48..ddc3d7293f 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -257,7 +257,8 @@ proc errorUseQualifier*(c: PContext; info: TLineInfo; s: PSym) = while candidate != nil: if i == 0: err.add " --use one of the following:\n" else: err.add "\n" - err.add candidate.owner.name.s & "." & typeToString(candidate.typ) + err.add candidate.owner.name.s & "." & candidate.name.s + err.add ": " & typeToString(candidate.typ) candidate = nextIdentIter(ti, c.importTable.symbols) inc i localError(c.config, info, errGenerated, err) From 93edefbf5b5d8c99551b80b00655bf32056b186a Mon Sep 17 00:00:00 2001 From: Julian Fondren Date: Sun, 28 Apr 2019 09:34:08 -0500 Subject: [PATCH 4/6] add indent to ambiguous-identifier output --- compiler/lookups.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index ddc3d7293f..89883d452c 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -257,7 +257,7 @@ proc errorUseQualifier*(c: PContext; info: TLineInfo; s: PSym) = while candidate != nil: if i == 0: err.add " --use one of the following:\n" else: err.add "\n" - err.add candidate.owner.name.s & "." & candidate.name.s + err.add " " & candidate.owner.name.s & "." & candidate.name.s err.add ": " & typeToString(candidate.typ) candidate = nextIdentIter(ti, c.importTable.symbols) inc i From 8274c0c6b34ebb11d5bb9083ef59b4182e95ae8d Mon Sep 17 00:00:00 2001 From: Julian Fondren Date: Mon, 29 Apr 2019 10:39:26 -0500 Subject: [PATCH 5/6] balance space around emdash -- --- compiler/lookups.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 89883d452c..7c37817fda 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -255,7 +255,7 @@ proc errorUseQualifier*(c: PContext; info: TLineInfo; s: PSym) = var candidate = initIdentIter(ti, c.importTable.symbols, s.name) var i = 0 while candidate != nil: - if i == 0: err.add " --use one of the following:\n" + if i == 0: err.add " -- use one of the following:\n" else: err.add "\n" err.add " " & candidate.owner.name.s & "." & candidate.name.s err.add ": " & typeToString(candidate.typ) From 6dfde0e931176405491987e14969f68d81957730 Mon Sep 17 00:00:00 2001 From: Julian Fondren Date: Mon, 29 Apr 2019 23:15:10 -0500 Subject: [PATCH 6/6] fix test expecting ambiguous-identifier error the test is only against the first line, but testament doens't support multi-line error messages yet. --- tests/modules/tambig_range.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/modules/tambig_range.nim b/tests/modules/tambig_range.nim index 0103505210..e1ecc00138 100644 --- a/tests/modules/tambig_range.nim +++ b/tests/modules/tambig_range.nim @@ -1,6 +1,6 @@ discard """ - errormsg: "ambiguous identifier: 'range' --use system.range or mrange.range" - line: 13 + errormsg: "ambiguous identifier: 'range' -- use one of the following:" + line: "13" """ import mrange