Skip to content

Commit

Permalink
added an .assert pragma and mentioned the pragmas in the changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Apr 2, 2020
1 parent df8e0e7 commit d01fca9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/sempass2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
4 changes: 2 additions & 2 deletions compiler/wordrecg.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit d01fca9

Please sign in to comment.