mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 06:18:51 +00:00
fixes #23749, refs #22716 `semIndirectOp` is used here because of the callback expressions, in this case `db.getProc(...)`, and `semIndirectOp` calls `semOpAux` to type its arguments before overloading starts. Hence it can opt in to symchoices since overloading will resolve them.
38 lines
866 B
Nim
38 lines
866 B
Nim
discard """
|
|
action: compile
|
|
"""
|
|
|
|
{.pragma: callback, gcsafe, raises: [].}
|
|
|
|
type
|
|
DataProc* = proc(val: openArray[byte]) {.callback.}
|
|
GetProc = proc (db: RootRef, key: openArray[byte], onData: DataProc): bool {.nimcall, callback.}
|
|
KvStoreRef* = ref object
|
|
obj: RootRef
|
|
getProc: GetProc
|
|
|
|
template get(dbParam: KvStoreRef, key: openArray[byte], onData: untyped): bool =
|
|
let db = dbParam
|
|
db.getProc(db.obj, key, onData)
|
|
|
|
func decode(input: openArray[byte], maxSize = 128): seq[byte] =
|
|
@[]
|
|
|
|
proc getSnappySSZ(db: KvStoreRef, key: openArray[byte]): string =
|
|
var status = "not found"
|
|
proc decode(data: openArray[byte]) =
|
|
status =
|
|
if true: "found"
|
|
else: "corrupted"
|
|
discard db.get(key, decode)
|
|
status
|
|
|
|
|
|
var ksr: KvStoreRef
|
|
var k = [byte(1), 2, 3, 4, 5]
|
|
|
|
proc foo(): string =
|
|
getSnappySSZ(ksr, toOpenArray(k, 1, 3))
|
|
|
|
echo foo()
|