Open
Description
Description
Minimal reproduction:
import options
type
Node[T] = ref object
value: T
previous: Option[Node[T]]
next: Option[Node[T]]
LinkedList*[T] = object ## A doubly linked list.
first: Option[Node[T]]
last: Option[Node[T]]
var list = LinkedList[int]()
# let qwerqwer = list.first.get.next
# This ^ line errors on stable (1.6.12), but not on current devel 1.9.1 (f7e3af0c2d68035a649cf9449cc4e02a7ea59e84)
let newNode = Node[int](value: 0,
next: list.first.get.next,
previous: Node[int].none).some
Nim Version
Nim Compiler Version 1.9.1 [Linux: amd64]
Compiled at 2023-03-21
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: f7e3af0
active boot switches: -d:release
Current Output
nim r -f -r "/home/konrad/.config/VSCodium/User/globalStorage/buenon.scratchpads/scratchpads/56b8016bc5c16deae167b5cfb0a76e9f/scratch8.nim"
Hint: used config file '/home/konrad/.choosenim/toolchains/nim-#devel/config/nim.cfg' [Conf]
Hint: used config file '/home/konrad/.choosenim/toolchains/nim-#devel/config/config.nims' [Conf]
..........................................................................
/home/konrad/.config/VSCodium/User/globalStorage/buenon.scratchpads/scratchpads/56b8016bc5c16deae167b5cfb0a76e9f/scratch8.nim(14, 5) Hint: 'newNode' is declared but not used [XDeclaredButNotUsed]
CC: ../../../../../../../.choosenim/toolchains/nim-#devel/lib/system/exceptions.nim
CC: ../../../../../../../.choosenim/toolchains/nim-#devel/lib/std/private/digitsutils.nim
CC: ../../../../../../../.choosenim/toolchains/nim-#devel/lib/std/assertions.nim
CC: ../../../../../../../.choosenim/toolchains/nim-#devel/lib/system/dollars.nim
CC: ../../../../../../../.choosenim/toolchains/nim-#devel/lib/system.nim
CC: ../../../../../../../.choosenim/toolchains/nim-#devel/lib/pure/options.nim
CC: scratch8.nim
/home/konrad/.cache/nim/scratch8_d/@mscratch8.nim.c: In function ‘NimMainModule’:
/home/konrad/.cache/nim/scratch8_d/@mscratch8.nim.c:574:20: error: ‘tyObject_Option__iPwdvoo5DamSoOdiAagILA’ has no member named ‘has’
574 | (*T1_).next.has = colontmpD_.has;
| ^
/home/konrad/.cache/nim/scratch8_d/@mscratch8.nim.c:574:37: error: ‘tyObject_Option__iPwdvoo5DamSoOdiAagILA’ has no member named ‘has’
574 | (*T1_).next.has = colontmpD_.has;
| ^
Error: execution of an external compiler program 'gcc -c -w -fmax-errors=3 -pthread -I'/home/konrad/.choosenim/toolchains/nim-#devel/lib' -I/home/konrad/.config/VSCodium/User/globalStorage/buenon.scratchpads/scratchpads/56b8016bc5c16deae167b5cfb0a76e9f -o /home/konrad/.cache/nim/scratch8_d/@mscratch8.nim.c.o /home/konrad/.cache/nim/scratch8_d/@mscratch8.nim.c' failed with exit code: 1
Expected Output
No error
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
- This is a part of Exercism "Linked list" exercise, but I'm trying to solve it with options instead of nils.
- There's also something wrong going on when I change the
Node[T] = ref object
to justNode[T] = object
: compiler exits on "......" dots phase without any errors and leaves terminal without newline.