git @ Cat's Eye Technologies SixtyPical / c33e6ef
Assert that the loop variable is meaningful in repeat. Unit test. Chris Pressey 4 years ago
2 changed file(s) with 21 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
285285 # it will always be executed at least once, so analyze it having
286286 # been executed the first time.
287287 self.analyze_block(instr.block, context)
288
288 context.assert_meaningful(src)
289
289290 # now analyze it having been executed a second time, with the context
290291 # of it having already been executed.
291292 self.analyze_block(instr.block, context)
292
293 # NB I *think* that's enough... but it might not be?
293 context.assert_meaningful(src)
294
294295 elif opcode == 'copy':
295296 # check that their types are basically compatible
296297 if src.type == dest.type:
10161016 | }
10171017 ? UnmeaningfulReadError: y in main
10181018
1019 And if you trash the test expression (i.e. `z` in the below) inside the loop,
1020 this is an error too.
1021
1022 | word one : 0
1023 | word two : 0
1024 |
1025 | routine main
1026 | inputs one, two
1027 | outputs two
1028 | trashes a, z, n
1029 | {
1030 | repeat {
1031 | copy one, two
1032 | } until z
1033 | }
1034 ? UnmeaningfulReadError: z in main
1035
10191036 ### copy ###
10201037
10211038 Can't `copy` from a memory location that isn't initialized.