mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-12 04:09:34 +00:00
16 lines
468 B
Nim
16 lines
468 B
Nim
# Helper for tinitorder (not a test itself; no `discard`).
|
|
#
|
|
# An imported module whose INIT sets module-level state at runtime. Under the
|
|
# per-module backend its init must run BEFORE any importer's init (the imported
|
|
# module is a dependency → post-order). With the buggy importer-first order this
|
|
# module's `setupB` runs too late and importers observe `gBState == 0`.
|
|
|
|
var gBState: int
|
|
|
|
proc getBState*(): int = gBState
|
|
|
|
proc setupB() =
|
|
gBState = 42
|
|
|
|
setupB()
|