Nim
Nim copied to clipboard
nim-devel regression: Nested generic types construction via template cannot instantiate
Description
import
std/options
type
BID = string or uint64
Future[T] = ref object of RootObj
internalValue: T
InternalRaisesFuture[T] = ref object of Future[T]
proc newInternalRaisesFutureImpl[T](): InternalRaisesFuture[T] =
let fut = InternalRaisesFuture[T]()
template newFuture[T](): auto =
newInternalRaisesFutureImpl[T]()
proc problematic(blockId: BID): Future[Option[seq[int]]] =
let resultFuture = newFuture[Option[seq[int]]]()
return resultFuture
let x = problematic("latest")
Nim Version
Nim Compiler Version 2.1.1 [Windows: amd64] Compiled at 2024-01-23 Copyright (c) 2006-2024 by Andreas Rumpf
git hash: be0b8472130112ad570a6720a0e3a34e67936619 active boot switches: -d:release
Current Output
...\bug.nim(22, 20) template/generic instantiation of `problematic` from here
...\bug.nim(19, 38) Error: cannot instantiate Option [type declared in ...\nim\lib\pure\options.nim(91, 3)]
got: <T>
but expected: <T>
Expected Output
no error
Possible Solution
No response
Additional Information
This code is part of nim-chronos, and it works fine with nim 1.6.18 and nim 2.0.3