From 446e5fbbb3941820847ad209576493a73d78bb61 Mon Sep 17 00:00:00 2001 From: metagn Date: Wed, 24 May 2023 21:39:40 +0300 Subject: when T is both a type symbol and a routine symbol in scope of a generic proc do not account for the type symbol when doing `a.T()` (#21899) fix #21883 --- compiler/semgnrc.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'compiler') diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index 7dec8a30d..44f396996 100644 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -138,7 +138,8 @@ proc newDot(n, b: PNode): PNode = result.add(b) proc fuzzyLookup(c: PContext, n: PNode, flags: TSemGenericFlags, - ctx: var GenericCtx; isMacro: var bool): PNode = + ctx: var GenericCtx; isMacro: var bool; + inCall = false): PNode = assert n.kind == nkDotExpr semIdeForTemplateOrGenericCheck(c.config, n, ctx.cursorInBody) @@ -152,8 +153,9 @@ proc fuzzyLookup(c: PContext, n: PNode, flags: TSemGenericFlags, result = n let n = n[1] let ident = considerQuotedIdent(c, n) - var candidates = searchInScopesFilterBy(c, ident, routineKinds+{skType}) - # skType here because could be type conversion + # could be type conversion if like a.T and not a.T() + let symKinds = if inCall: routineKinds else: routineKinds+{skType} + var candidates = searchInScopesFilterBy(c, ident, symKinds) if candidates.len > 0: let s = candidates[0] # XXX take into account the other candidates! isMacro = s.kind in {skTemplate, skMacro} @@ -281,7 +283,7 @@ proc semGenericStmt(c: PContext, n: PNode, onUse(fn.info, s) first = 1 elif fn.kind == nkDotExpr: - result[0] = fuzzyLookup(c, fn, flags, ctx, mixinContext) + result[0] = fuzzyLookup(c, fn, flags, ctx, mixinContext, inCall = true) first = 1 # Consider 'when declared(globalsSlot): ThreadVarSetValue(globalsSlot, ...)' # in threads.nim: the subtle preprocessing here binds 'globalsSlot' which -- cgit 1.4.1-2-gfad0 r'>author
path: root/build_all.bat
blob: ef4a5f6a4e786e384d9cd9390aa0e8b1f50d436e (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12