Reloading a script is supposed to reload its dependants, but that isn't happening for hot reload (file-watcher) or wait_for_script-triggered reloads. Scripts compiled against a prototype keep the old generated type after the prototype's module reloads, producing confusing type-mismatch errors until each dependent is manually re-touched, in dependency order.
Repro
Three scripts in a level:
build_door.nim — name Door(open = false, door_width = 6, door_height = 8) + drawing + state machine
build_button.nim — name Button(door = Door, pause = 5) (proto object as param default, per tutorial-3)
build_demo_doorway.nim — spawner: let d = Door.new(...); Button.new(door = d, ...)
Steps:
- Load all three (works).
- Edit
build_door.nim (any change to the name line or body), let it hot-reload.
- Touch/reload the spawner.
Expected
build_button (whose .new signature embeds Doortype via door = Door) recompiles against the new Door module; the spawner then compiles and runs.
Actual
The spawner fails with a type mismatch — door = d where d: Doortype doesn't match Button's recorded door = Door param, because Button still references the previous compilation's Doortype symbol:
Error: type mismatch
Expression: new(Button, position = vec3(-38, 0, 36), door = d, color = red)
...
[3] proc new(instance: Buttontype; door = Door; pause = 5; ...): Buttontype
(First mismatch at the door arg even though both sides print as Doortype.)
Workaround
Touch dependents manually in dependency order, waiting for each: build_button.nim → wait → build_demo_doorway.nim. Hit twice in one session while iterating on the Door proto.
Related
Same family as the load-order race where a spawner compiles before its proto registers ("undeclared identifier: Tower") and needs a retry — both would be covered by recompiling/requeueing dependents whenever a proto module (re)loads.
Reloading a script is supposed to reload its dependants, but that isn't happening for hot reload (file-watcher) or
wait_for_script-triggered reloads. Scripts compiled against a prototype keep the old generated type after the prototype's module reloads, producing confusing type-mismatch errors until each dependent is manually re-touched, in dependency order.Repro
Three scripts in a level:
build_door.nim—name Door(open = false, door_width = 6, door_height = 8)+ drawing + state machinebuild_button.nim—name Button(door = Door, pause = 5)(proto object as param default, per tutorial-3)build_demo_doorway.nim— spawner:let d = Door.new(...); Button.new(door = d, ...)Steps:
build_door.nim(any change to thenameline or body), let it hot-reload.Expected
build_button(whose.newsignature embedsDoortypeviadoor = Door) recompiles against the new Door module; the spawner then compiles and runs.Actual
The spawner fails with a type mismatch —
door = dwhered: Doortypedoesn't match Button's recordeddoor = Doorparam, because Button still references the previous compilation'sDoortypesymbol:(First mismatch at the
doorarg even though both sides print asDoortype.)Workaround
Touch dependents manually in dependency order, waiting for each:
build_button.nim→ wait →build_demo_doorway.nim. Hit twice in one session while iterating on the Door proto.Related
Same family as the load-order race where a spawner compiles before its proto registers ("undeclared identifier: Tower") and needs a retry — both would be covered by recompiling/requeueing dependents whenever a proto module (re)loads.