From 1c2abb8d880b8a7553251891e816617f060b6b69 Mon Sep 17 00:00:00 2001 From: cooldome Date: Fri, 25 Jan 2019 08:25:11 +0000 Subject: [PATCH] fixes double object field symbol lookups (no test case available) (#10450) --- compiler/semexprs.nim | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 37e2ca33f8..68f1c6c3a7 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -1291,7 +1291,11 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode = if ty.sons[0] == nil: break ty = skipTypes(ty.sons[0], skipPtrs) if f != nil: - if fieldVisible(c, f): + let visibilityCheckNeeded = + if n[1].kind == nkSym and n[1].sym == f: + false # field lookup was done already, likely by hygienic template or bindSym + else: true + if not visibilityCheckNeeded or fieldVisible(c, f): # is the access to a public field or in the same module or in a friend? markUsed(c.config, n.sons[1].info, f, c.graph.usageSym) onUse(n.sons[1].info, f)