mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
* .forbids pragma: defining illegal effects for proc types This patch intends to define the opposite of the .tags pragma: a way to define effects which are not allowed in a proc. * updated documentation and changelogs for the forbids pragma * renamed notTagEffects to forbiddenEffects * corrected issues of forbids pragma the forbids pragma didn't handle simple restrictions properly and it also had issues with subtyping * removed incorrect character from changelog * added test to cover the interaction of methods and the forbids pragma * covering the interaction of the tags and forbids pragmas * updated manual about the forbids pragma * removed useless statement * corrected the subtyping of proc types using the forbids pragma * updated manual for the forbids pragma * updated documentations for forbids pragma * updated nim docs * updated docs with rsttester.nim * regenerated documentation * updated rst docs * Update changelog.md Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com> * updated changelog * corrected typo Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
22 lines
447 B
Nim
22 lines
447 B
Nim
discard """
|
|
action: compile
|
|
errormsg: "type mismatch: got <proc (x: int){.gcsafe, locks: 0.}>"
|
|
line: 21
|
|
"""
|
|
|
|
type
|
|
Effect1 = object
|
|
Effect2 = object
|
|
Effect3 = object
|
|
|
|
proc test(fnc: proc(x: int): void {.forbids: [Effect2].}) {.tags: [Effect1, Effect3, RootEffect].} =
|
|
fnc(1)
|
|
|
|
proc t1(x: int): void = echo $x
|
|
proc t2(x: int): void {.tags: [Effect2].} = echo $x
|
|
proc t3(x: int): void {.tags: [Effect3].} = echo $x
|
|
|
|
test(t1)
|
|
test(t3)
|
|
test(t2)
|