Skip to content

Commit

Permalink
actually test nim-lang#18212 and other routines
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Apr 12, 2023
1 parent cfdcb73 commit f72587f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
elif comesFromPush and whichKeyword(ident) != wInvalid:
discard "ignore the .push pragma; it doesn't apply"
else:
# semCustomPragma still gives appropriate error for invalid pragmas
# semCustomPragma gives appropriate error for invalid pragmas
n[i] = semCustomPragma(c, it, sym)

proc overwriteLineInfo(n: PNode; info: TLineInfo) =
Expand Down
29 changes: 28 additions & 1 deletion tests/pragmas/tcustom_pragma.nim
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,39 @@ block:

discard Hello(a: 1.0, b: 12)

# custom pragma on iterators
# test routines
block:
template prag {.pragma.}
proc hello {.prag.} = discard
iterator hello2: int {.prag.} = discard
template hello3(x: int): int {.prag.} = x
macro hello4(x: int): int {.prag.} = x
func hello5(x: int): int {.prag.} = x
doAssert hello.hasCustomPragma(prag)
doAssert hello2.hasCustomPragma(prag)
doAssert hello3.hasCustomPragma(prag)
doAssert hello4.hasCustomPragma(prag)
doAssert hello5.hasCustomPragma(prag)

# test push doesn't break
block:
template prag {.pragma.}
{.push prag.}
proc hello = discard
iterator hello2: int = discard
template hello3(x: int): int = x
macro hello4(x: int): int = x
func hello5(x: int): int = x
type
Foo = enum a
Bar[T] = ref object of RootObj
x: T
case y: bool
of false: discard
else:
when true: discard
for a in [1]: discard a
{.pop.}

# issue #11511
when false:
Expand Down

0 comments on commit f72587f

Please sign in to comment.