nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.63k stars 1.47k forks source link

segfault compiling typedef with higher-order procs #5631

Open evacchi opened 7 years ago

evacchi commented 7 years ago

segfaults:

type
  Behavior = proc(): Effect
  Effect   = proc(behavior: Behavior): Behavior

works if I wrap Effect in an object:

type
  Behavior = proc(): Effect
  Effect   = object
    eff: proc(behavior: Behavior): Behavior

(discovered while rewriting this Scala snippet in Nim)

Araq commented 7 years ago

Recursive type constructions need to go through a nominal type (like object).