git @ Cat's Eye Technologies SixtyPical / 3417fd9
Apparently this hack was only needed previously due to a bug? Chris Pressey 3 years ago
2 changed file(s) with 20 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
201201 // call clear_screen
202202 // call init_game
203203 copy game_state_play, dispatch_game_state
204 } else {
205 // This is sort of a hack. FIXME: let `if` branches diverge this much.
206 copy forward game_state_title_screen, dispatch_game_state
207204 }
208205
209206 goto save_cinv
10631063 | }
10641064 | }
10651065 ? InconsistentInitializationError: x
1066
1067 However, this only pertains to initialization. If a value is already
1068 initialized, either because it was set previous to the `if`, or is an
1069 input to the routine, and it is initialized in one branch, it need not
1070 be initialized in the other.
1071
1072 | routine foo
1073 | inputs x
1074 | outputs x
1075 | trashes a, z, n, c
1076 | {
1077 | ld a, 0
1078 | cmp a, 42
1079 | if z {
1080 | ld x, 7
1081 | } else {
1082 | ld a, 23
1083 | }
1084 | }
1085 = ok
10661086
10671087 An `if` with a single block is analyzed as if it had an empty `else` block.
10681088