Nim Version
Nim Compiler Version 2.3.1 [Linux: arm64]
Compiled at 2026-04-30
Copyright (c) 2006-2026 by Andreas Rumpf
git hash: 92d0c09
active boot switches: -d:release
Description
Compiling following code generates compile error: object constructor needs an object type [forward declared in testobjcon3.nim(5, 3)]
type
Foo = object
x = Bar()
Bar = object
x: int
var f = Foo()
echo f.x
Current Output
testobjcon3.nim(3, 12) Error: object constructor needs an object type [forward declared in testobjcon3.nim(5, 3)]
Expected Output
Known Workarounds
Declaring Bar before Foo compiles without error:
type
Bar = object
x: int
Foo = object
x = Bar()
var f = Foo()
echo f.x
Additional Information
No response
Nim Version
Nim Compiler Version 2.3.1 [Linux: arm64]
Compiled at 2026-04-30
Copyright (c) 2006-2026 by Andreas Rumpf
git hash: 92d0c09
active boot switches: -d:release
Description
Compiling following code generates compile error:
object constructor needs an object type [forward declared in testobjcon3.nim(5, 3)]Current Output
Expected Output
Known Workarounds
Declaring
BarbeforeFoocompiles without error:Additional Information
No response