out parameters: enforce that 'out' is only used as a parameter (#20510)

* out parameters: enforce that 'out' is only used as a parameter

* make tables.nim use 'out' parameters

* better backwards compat
This commit is contained in:
Andreas Rumpf 2022-10-07 22:26:53 +02:00 • committed by GitHub
commit e83f27e6a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 3 deletions

View file

@ -13,6 +13,7 @@
when defined(nimPreviewSlimSystem):
import std/assertions
import std / outparams
const
growthFactor = 2
@ -78,5 +79,5 @@ template rawGetImpl() {.dirty.} =
genHashImpl(key, hc)
rawGetKnownHCImpl()
proc rawGet[X, A](t: X, key: A, hc: var Hash): int {.inline.} =
proc rawGet[X, A](t: X, key: A, hc: var Hash): int {.inline, outParamsAt: [3].} =
rawGetImpl()

View file

@ -23,7 +23,7 @@ template rawInsertImpl() {.dirty.} =
data[h].val = val
data[h].hcode = hc
proc rawGetDeep[X, A](t: X, key: A, hc: var Hash): int {.inline.} =
proc rawGetDeep[X, A](t: X, key: A, hc: var Hash): int {.inline, outParamsAt: [3].} =
rawGetDeepImpl()
proc rawInsert[X, A, B](t: var X, data: var KeyValuePairSeq[A, B],