make two-argument withValues untyped (#26052)

The twp-argument form of `withValue` are expression when the branches
themselves are expressions.

(cherry picked from commit 8d18bdb3dc)
This commit is contained in:
Jacek Sieka
2026-08-03 11:55:32 +02:00
committed by narimiran
parent a2cf8e0ced
commit 09cefd62d8
3 changed files with 19 additions and 3 deletions

View File

@@ -95,7 +95,7 @@ template withValue*[A, B](t: var SharedTable[A, B], key: A,
release(t.lock)
template withValue*[A, B](t: var SharedTable[A, B], key: A,
value, body1, body2: untyped) =
value, body1, body2: untyped): untyped =
## Retrieves the value at `t[key]`.
## `value` can be modified in the scope of the `withValue` call.
runnableExamples:

View File

@@ -636,7 +636,7 @@ template withValue*[A, B](t: var Table[A, B], key: A, value, body: untyped) =
body
template withValue*[A, B](t: var Table[A, B], key: A,
value, body1, body2: untyped) =
value, body1, body2: untyped): untyped =
## Retrieves the value at `t[key]`.
##
## `value` can be modified in the scope of the `withValue` call.
@@ -677,7 +677,7 @@ template withValue*[A, B](t: var Table[A, B], key: A,
body2
template withValue*[A, B](t: Table[A, B], key: A,
value, body1, body2: untyped) =
value, body1, body2: untyped): untyped =
## Retrieves the value at `t[key]` if it exists, assigns
## it to the variable `value` and executes `body`
runnableExamples: