* implements https://github.com/nim-lang/RFCs/issues/258

* don't be too strict with custom pragma blocks

* cast pragmas: documentation

* added most missing inference query procs to effecttraits.nim
This commit is contained in:
Andreas Rumpf 2020-10-06 16:47:15 +02:00 • committed by GitHub
commit 92163fa330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 232 additions and 68 deletions

View file

@ -130,7 +130,19 @@ proc isRange*(n: PNode): bool {.inline.} =
proc whichPragma*(n: PNode): TSpecialWord =
let key = if n.kind in nkPragmaCallKinds and n.len > 0: n[0] else: n
if key.kind == nkIdent: result = whichKeyword(key.ident)
case key.kind
of nkIdent: result = whichKeyword(key.ident)
of nkSym: result = whichKeyword(key.sym.name)
of nkCast: result = wCast
of nkClosedSymChoice, nkOpenSymChoice:
result = whichPragma(key[0])
else: result = wInvalid
proc isNoSideEffectPragma*(n: PNode): bool =
var k = whichPragma(n)
if k == wCast:
k = whichPragma(n[1])
result = k == wNoSideEffect
proc findPragma*(n: PNode, which: TSpecialWord): PNode =
if n.kind == nkPragma: