Skip to content

Commit

Permalink
fix nim-lang#13524 astToStr now works inside generics
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Mar 18, 2020
1 parent 090a418 commit ec828ea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions compiler/semgnrc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,7 @@ proc semGenericStmt(c: PContext, n: PNode,
var mixinContext = false
if s != nil:
incl(s.flags, sfUsed)
# more robust/future proof than:
# mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles, mAstToStr}
if s.magic != mNone and s.typ != nil:
for i in 1..<s.typ.len:
if s.typ[i].kind == tyUntyped:
mixinContext = true
break

mixinContext = s.magic in {mDefined, mDefinedInScope, mCompiles, mAstToStr}
let sc = symChoice(c, fn, s, if s.isMixedIn: scForceOpen else: scOpen)
case s.kind
of skMacro:
Expand Down Expand Up @@ -290,9 +283,6 @@ proc semGenericStmt(c: PContext, n: PNode,
# is not exported and yet the generic 'threadProcWrapper' works correctly.
let flags = if mixinContext: flags+{withinMixin} else: flags
for i in first..<result.safeLen:
# instead, would be better to only set `withinMixin` for arguments of
# kind tyUntyped, eg `if s.typ[i].kind == tyUntyped:`, however, this
# currently doesn't work
result[i] = semGenericStmt(c, result[i], flags, ctx)
of nkCurlyExpr:
result = newNodeI(nkCall, n.info)
Expand Down
2 changes: 1 addition & 1 deletion lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ else:
result[i+1] = y[i]


proc astToStr*(x: untyped): string {.magic: "AstToStr", noSideEffect.}
proc astToStr*[T](x: T): string {.magic: "AstToStr", noSideEffect.}
## Converts the AST of `x` into a string representation. This is very useful
## for debugging.

Expand Down

0 comments on commit ec828ea

Please sign in to comment.