From 0eca832cf7af958174d011eba90260de432d3101 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Mon, 19 Apr 2021 18:51:56 -0700 Subject: [PATCH 1/2] `--declaredlocs` now shows location for `T` instead of `static` in `proc fn(a: static T)` --- compiler/types.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/types.nim b/compiler/types.nim index ba2cc76ce1dad..26c35a290e012 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -124,6 +124,9 @@ proc isFloatLit*(t: PType): bool {.inline.} = result = t.kind == tyFloat and t.n != nil and t.n.kind == nkFloatLit proc addDeclaredLoc*(result: var string, conf: ConfigRef; sym: PSym) = + var sym = sym + while sym.typ.kind in {tyStatic}: + sym = sym.typ[0].sym result.add " [$1 declared in $2]" % [sym.kind.toHumanStr, toFileLineCol(conf, sym.info)] proc addDeclaredLocMaybe*(result: var string, conf: ConfigRef; sym: PSym) = @@ -131,7 +134,10 @@ proc addDeclaredLocMaybe*(result: var string, conf: ConfigRef; sym: PSym) = addDeclaredLoc(result, conf, sym) proc addDeclaredLoc*(result: var string, conf: ConfigRef; typ: PType) = - let typ = typ.skipTypes(abstractInst - {tyRange}) + # xxx figure out how to resolve `tyGenericParam`, e.g. for + # proc fn[T](a: T, b: T) = discard + # fn(1.1, "a") + let typ = typ.skipTypes(abstractInst + {tyStatic} - {tyRange}) result.add " [$1" % typ.kind.toHumanStr if typ.sym != nil: result.add " declared in " & toFileLineCol(conf, typ.sym.info) From 2979ee508fa60d846e6c15b336534dbd70aa29aa Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Tue, 20 Apr 2021 01:14:30 -0700 Subject: [PATCH 2/2] fixup --- compiler/types.nim | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/types.nim b/compiler/types.nim index 26c35a290e012..b57e4644437f2 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -124,9 +124,6 @@ proc isFloatLit*(t: PType): bool {.inline.} = result = t.kind == tyFloat and t.n != nil and t.n.kind == nkFloatLit proc addDeclaredLoc*(result: var string, conf: ConfigRef; sym: PSym) = - var sym = sym - while sym.typ.kind in {tyStatic}: - sym = sym.typ[0].sym result.add " [$1 declared in $2]" % [sym.kind.toHumanStr, toFileLineCol(conf, sym.info)] proc addDeclaredLocMaybe*(result: var string, conf: ConfigRef; sym: PSym) =