@@ -226,7 +226,14 @@ proc semGenericStmt(c: PContext, n: PNode,
226226 var mixinContext = false
227227 if s != nil :
228228 incl (s.flags, sfUsed)
229- mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles}
229+ # more robust/future proof than:
230+ # mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles, mAstToStr}
231+ if s.magic != mNone and s.typ != nil :
232+ for i in 1 ..< s.typ.len:
233+ if s.typ[i].kind == tyUntyped:
234+ mixinContext = true
235+ break
236+
230237 let sc = symChoice (c, fn, s, if s.isMixedIn: scForceOpen else : scOpen)
231238 case s.kind
232239 of skMacro:
@@ -283,6 +290,10 @@ proc semGenericStmt(c: PContext, n: PNode,
283290 # is not exported and yet the generic 'threadProcWrapper' works correctly.
284291 let flags = if mixinContext: flags+ {withinMixin} else : flags
285292 for i in first..< result .safeLen:
293+ let flags = if mixinContext: flags+ {withinMixin} else : flags
294+ # instead, would be better to only set `withinMixin` for arguments of
295+ # kind tyUntyped, eg `if s.typ[i].kind == tyUntyped:`, however, this
296+ # currentl doesn't work
286297 result [i] = semGenericStmt (c, result [i], flags, ctx)
287298 of nkCurlyExpr:
288299 result = newNodeI (nkCall, n.info)
0 commit comments