diff options
author | Araq <rumpf_a@web.de> | 2020-04-02 12:57:15 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2020-04-02 12:57:32 +0200 |
commit | d01fca974dd377b100bc3e2477d6d59f0a05517f (patch) | |
tree | 493f155149de389da90d7f93f7df997e4464b1df | |
parent | df8e0e7f0c3a2e340c625d8c55d9105da106dbfd (diff) | |
download | Nim-d01fca974dd377b100bc3e2477d6d59f0a05517f.tar.gz |
added an .assert pragma and mentioned the pragmas in the changelog
-rw-r--r-- | changelog.md | 4 | ||||
-rw-r--r-- | compiler/pragmas.nim | 2 | ||||
-rw-r--r-- | compiler/sempass2.nim | 2 | ||||
-rw-r--r-- | compiler/wordrecg.nim | 4 |
4 files changed, 8 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md index 32f6e0a1b..46b4a49b2 100644 --- a/changelog.md +++ b/changelog.md @@ -169,6 +169,10 @@ echo f enabling things like lvalue references, see `byaddr.byaddr` - `macro pragmas` can now be used in type sections. +- 5 new pragmas were added to Nim in order to make the upcoming tooling more + convenient to use. Nim compiler checks these pragmas for syntax but otherwise + ignores them. The pragmas are `requires`, `ensures`, `assume`, `assert`, `invariant`. + ## Language changes diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 6816a1705..4b0cf406d 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -1176,7 +1176,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, if sym == nil: invalidPragma(c, it) else: sym.flags.incl sfUsed of wLiftLocals: discard - of wRequires, wInvariant, wAssume: + of wRequires, wInvariant, wAssume, wAssert: pragmaProposition(c, it) of wEnsures: pragmaEnsures(c, it) diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index 86149330e..efc19952c 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -1030,7 +1030,7 @@ proc track(tracked: PEffects, n: PNode) = when defined(drnim): if pragma == wAssume: addFact(tracked.guards, pragmaList[i][1]) - elif pragma == wInvariant: + elif pragma == wInvariant or pragma == wAssert: if prove(tracked, pragmaList[i][1]): addFact(tracked.guards, pragmaList[i][1]) diff --git a/compiler/wordrecg.nim b/compiler/wordrecg.nim index 2ce2b9322..55c38b76a 100644 --- a/compiler/wordrecg.nim +++ b/compiler/wordrecg.nim @@ -54,7 +54,7 @@ type wNonReloadable, wExecuteOnReload, wAssertions, wPatterns, wTrMacros, wSinkInference, wWarnings, wHints, wOptimization, wRaises, wWrites, wReads, wSize, wEffects, wTags, - wRequires, wEnsures, wInvariant, wAssume, + wRequires, wEnsures, wInvariant, wAssume, wAssert, wDeadCodeElimUnused, # deprecated, dead code elim always happens wSafecode, wPackage, wNoForward, wReorder, wNoRewrite, wNoDestroy, wPragma, @@ -143,7 +143,7 @@ const "assertions", "patterns", "trmacros", "sinkinference", "warnings", "hints", "optimization", "raises", "writes", "reads", "size", "effects", "tags", - "requires", "ensures", "invariant", "assume", + "requires", "ensures", "invariant", "assume", "assert", "deadcodeelim", # deprecated, dead code elim always happens "safecode", "package", "noforward", "reorder", "norewrite", "nodestroy", "pragma", |