Open konradmb opened 1 year ago
Might be a duplicate of https://github.com/nim-lang/Nim/issues/16754
@Yardanico I can reproduce this one on --gc:none
, --gc:arc
, --gc:orc
, --gc:refc
. Although error messages are slightly different, it still generally boils down to "...has no member named ‘has’"
Also, compiler probably crashes with normal object (not ref).
This:
import options
type
NodeObj[T] = object
value: T
previous: Option[ref NodeObj[T]]
next: Option[ref NodeObj[T]]
Node[T] = ref NodeObj[T]
LinkedList*[T] = object ## A doubly linked list.
first: Option[Node[T]]
last: Option[Node[T]]
var list = LinkedList[int]()
let newNode = Node[int](value: 0,
next: list.first.get.next,
previous: Node[int].none).some
gives:
prog.nim(17Error: unhandled exception: Can't obtain a value from a `none` [UnpackDefect]
While a similar workaround works for #16754
Edit: Actually this is probably the expected behavior of this code, so this workaround seems to work here as well
Description
Minimal reproduction:
Nim Version
Nim Compiler Version 1.9.1 [Linux: amd64] Compiled at 2023-03-21 Copyright (c) 2006-2023 by Andreas Rumpf
git hash: f7e3af0c2d68035a649cf9449cc4e02a7ea59e84 active boot switches: -d:release
Current Output
Expected Output
Possible Solution
Elegantbeef from Matrix says it is a "cgen bug For some reason it's calling .has for a Option[ref] even though it shouldnt"
Additional Information
Node[T] = ref object
to justNode[T] = object
: compiler exits on "......" dots phase without any errors and leaves terminal without newline.