flatty
flatty copied to clipboard
Unable to deserialize object
Hi, I was trying to serialize and deserialize bloom filter object, and deserialization gives me the following error during the compilation:
flatty-0.3.4/flatty.nim(171, 23) Error: for a 'var' type a variable needs to be passed; but 'uint64(x.capacity)' is immutable
code causing the issue is:
proc importFlatty*(srcPath: string): Bloom =
result = srcPath.readFile().fromFlatty(Bloom)
and it works perfectly the opposite way (toFlatty).
Is that a bug or me doing something wrong?
This looks like a bug. Could you provide a small example to reproduce this?
You might need to include the bloom filter import in the same file as the code that is doing the deserialization. Some times Nim is confusing with imports.
On Thu, Sep 22, 2022, at 3:02 AM, srozb wrote:
Hi, I was trying to serialize and deserialize bloom filter object https://github.com/dizzyliam/flower/blob/main/src/flower.nim#L17, and deserialization gives me the following error during the compilation:
flatty-0.3.4/flatty.nim(171, 23) Error: for a 'var' type a variable needs to be passed; but 'uint64(x.capacity)' is immutablecode causing the issue is:proc importFlatty*(srcPath: string): Bloom = result = srcPath.readFile().fromFlatty(Bloom) and it works perfectly the opposite way (
toFlatty).Is that a bug or me doing something wrong?
— Reply to this email directly, view it on GitHub https://github.com/treeform/flatty/issues/34, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA6X7EC2ACXKX6RL6BNPKTV7QVFHANCNFSM6AAAAAAQS4IFWI. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Here's the minimal example:
import flower, flatty
var
bloom = newBloom(10, 0.01)
bl = fromFlatty(toFlatty(bloom), Bloom)
nim c -r test.nim
/Users/slawek/tmp/bloombug/test.nim(5, 18) template/generic instantiation of `fromFlatty` from here
/Users/slawek/.nimble/pkgs/flatty-0.3.4/flatty.nim(291, 4) template/generic instantiation of `fromFlatty` from here
/Users/slawek/.nimble/pkgs/flatty-0.3.4/flatty.nim(171, 23) Error: for a 'var' type a variable needs to be passed; but 'uint64(x.capacity)' is immutable
Tested with flatty [0.3.4] and flower [1.0.0]. Imports included in the same file.