Hi, I am trying to use concepts and have a question about this.
I have the following code and this compiled successfully.
type C = concept x
x.val is int
type X = object
val: int
proc initX(val: int): X = X(val: val)
let x: C = initX(1)
echo(x.val)
However, the following code generated error.
type C = concept x
x.val is int
type X = object
val: int
let x: C = X(val: 1)
echo(x.val)
Error:
walkre@DESKTOP-07UPQ8F:tmp$ nim c --run concepttest.nim
Hint: used config file '/home/walkre/.choosenim/toolchains/nim-0.19.0/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: concepttest [Processing]
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Is the first code valid? If so, what is the difference between these codes?