parent
064fe18de6
commit
b7ad29e692
3 changed files with 21 additions and 2 deletions
|
|
@ -610,8 +610,6 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||||
s.owner.name.s == "vm" and s.name.s == "stackTrace":
|
s.owner.name.s == "vm" and s.name.s == "stackTrace":
|
||||||
incl(s.flags, sfCallsite)
|
incl(s.flags, sfCallsite)
|
||||||
|
|
||||||
s.ast = n
|
|
||||||
|
|
||||||
styleCheckDef(c.config, s)
|
styleCheckDef(c.config, s)
|
||||||
onDef(n[namePos].info, s)
|
onDef(n[namePos].info, s)
|
||||||
# check parameter list:
|
# check parameter list:
|
||||||
|
|
@ -664,6 +662,12 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||||
semIdeForTemplateOrGeneric(c, n[bodyPos], ctx.cursorInBody)
|
semIdeForTemplateOrGeneric(c, n[bodyPos], ctx.cursorInBody)
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
popOwner(c)
|
popOwner(c)
|
||||||
|
|
||||||
|
# set the symbol AST after pragmas, at least. This stops pragma that have
|
||||||
|
# been pushed (implicit) to be explicitly added to the template definition
|
||||||
|
# and misapplied to the body. see #18113
|
||||||
|
s.ast = n
|
||||||
|
|
||||||
if sfCustomPragma in s.flags:
|
if sfCustomPragma in s.flags:
|
||||||
if n[bodyPos].kind != nkEmpty:
|
if n[bodyPos].kind != nkEmpty:
|
||||||
localError(c.config, n[bodyPos].info, errImplOfXNotAllowed % s.name.s)
|
localError(c.config, n[bodyPos].info, errImplOfXNotAllowed % s.name.s)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
errormsg: "'untyped' is only allowed in templates and macros or magic procs"
|
errormsg: "'untyped' is only allowed in templates and macros or magic procs"
|
||||||
|
disabled: true
|
||||||
"""
|
"""
|
||||||
|
|
||||||
template something(op: proc (v: untyped): void): void =
|
template something(op: proc (v: untyped): void): void =
|
||||||
|
|
|
||||||
14
tests/template/t18113.nim
Normal file
14
tests/template/t18113.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
# ensure template pragma handling doesn't eagerly attempt to add an implicit
|
||||||
|
# 'pushed' pragma to the evaluation of any intermediate AST prior to
|
||||||
|
# substitution.
|
||||||
|
|
||||||
|
# bug #18113
|
||||||
|
|
||||||
|
import sequtils
|
||||||
|
|
||||||
|
{.push raises: [Defect].}
|
||||||
|
|
||||||
|
var a = toSeq([1, 2, 3, 5, 10]).filterIt(it > 5)
|
||||||
|
|
||||||
|
doAssert a.len == 1
|
||||||
|
doAssert a[0] == 10
|
||||||
Loading…
Add table
Add a link
Reference in a new issue