-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
DocumentationRelated to documentation content (not generation).Related to documentation content (not generation).Medium PriorityRecursive/Forward TypesType Sections
Description
The following code produces f.nim(17, 17) Error: invalid type: 'ArgsDef' in this context: 'proc (name: string, valueType: int): ArgDef'
type
ParserThunk[T] = (proc(): T)
ArgDefType* = enum
adtValue
adtMoreArgs
ArgDef* = ref object
case typ*: ArgDefType
of adtValue:
valueType: int
of adtMoreArgs:
args*: ParserThunk[ArgsDef]
ArgsDef* = ParserThunk[seq[ArgDef]]
proc valueArgDef(name: string, valueType: int): ArgDef =
new(result)
result.typ = adtValue
result.valueType = valueType
However, this compiles (ArgsDef is 'inlined'):
type
ParserThunk[T] = (proc(): T)
ArgDefType* = enum
adtValue
adtMoreArgs
ArgDef* = ref object
case typ*: ArgDefType
of adtValue:
valueType: int
of adtMoreArgs:
args*: ParserThunk[ParserThunk[seq[ArgDef]]]
proc valueArgDef(name: string, valueType: int): ArgDef =
new(result)
result.typ = adtValue
result.valueType = valueType
Other simplification, such as removing case type make this code compile. I've also managed to produce longer variations of this which crash the compiler.
Metadata
Metadata
Assignees
Labels
DocumentationRelated to documentation content (not generation).Related to documentation content (not generation).Medium PriorityRecursive/Forward TypesType Sections