From e83f27e6a0f52f167e8eb91cd8f60be62d6725c6 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Fri, 7 Oct 2022 22:26:53 +0200 Subject: 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 --- lib/pure/collections/hashcommon.nim | 3 ++- lib/pure/collections/tableimpl.nim | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/pure') diff --git a/lib/pure/collections/hashcommon.nim b/lib/pure/collections/hashcommon.nim index deff8fa21..02312e2dc 100644 --- a/lib/pure/collections/hashcommon.nim +++ b/lib/pure/collections/hashcommon.nim @@ -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() diff --git a/lib/pure/collections/tableimpl.nim b/lib/pure/collections/tableimpl.nim index 27c339177..81079a3d1 100644 --- a/lib/pure/collections/tableimpl.nim +++ b/lib/pure/collections/tableimpl.nim @@ -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], -- cgit 1.4.1-2-gfad0