Open eienEika opened 1 year ago
Thanks for letting me know!
For an immediate workaround, use a cstring
. I will update the type checker to show an error for unsupported types.
It might be possible to support some heap types like string and seq as part of objects without degrading performance but I haven't had any great ideas so far.
@capocasa Confirmed still broken in Nim 2 with cstring
:
import limdb
import std/strformat
type
PersonCStr = object
name: cstring
age: Natural # Ensures the age is positive
let db = initDatabase("dbTestPersonCStr", (string, PersonCStr))
if "person" in db:
echo "reading"
echo db["person"]
else:
db["person"] = PersonCStr(name: "John", age: 45)
echo "saved"
Run this twice (once to save, once to read). Read on 2nd run fails at runtime:
reading
Traceback (most recent call last)
/home/winrid/CLionProjects/nimtest/main.nim(13) main
/home/winrid/.choosenim/toolchains/nim-2.0.0/lib/std/private/miscdollars.nim(31) $
/home/winrid/.choosenim/toolchains/nim-2.0.0/lib/system/iterators.nim(87) addQuoted
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Following code:
runs without error. But in next run (without resetting value) when you try read
db[1]
program crashes with SIGSEGV. Some remarks:Foo.a
is empty string works;string
andseq[string]
as db value works.Also for
Foo
as key there is another error. It doesn't compile because there are nocompare
procedure forstring, string
.Nim version 1.6.12 and devel, no matter of
--mm
is refc or arc/orc.