mirror of
https://github.com/catseye/SixtyPical.git
synced 2025-02-16 15:30:26 +00:00
Assert that the loop variable is meaningful in repeat. Unit test.
This commit is contained in:
parent
0e9a887ac5
commit
c33e6ef0e9
@ -286,12 +286,13 @@ class Analyzer(object):
|
||||
# it will always be executed at least once, so analyze it having
|
||||
# been executed the first time.
|
||||
self.analyze_block(instr.block, context)
|
||||
|
||||
context.assert_meaningful(src)
|
||||
|
||||
# now analyze it having been executed a second time, with the context
|
||||
# of it having already been executed.
|
||||
self.analyze_block(instr.block, context)
|
||||
|
||||
# NB I *think* that's enough... but it might not be?
|
||||
context.assert_meaningful(src)
|
||||
|
||||
elif opcode == 'copy':
|
||||
# check that their types are basically compatible
|
||||
if src.type == dest.type:
|
||||
|
@ -1017,6 +1017,23 @@ initialized at the start.
|
||||
| }
|
||||
? UnmeaningfulReadError: y in main
|
||||
|
||||
And if you trash the test expression (i.e. `z` in the below) inside the loop,
|
||||
this is an error too.
|
||||
|
||||
| word one : 0
|
||||
| word two : 0
|
||||
|
|
||||
| routine main
|
||||
| inputs one, two
|
||||
| outputs two
|
||||
| trashes a, z, n
|
||||
| {
|
||||
| repeat {
|
||||
| copy one, two
|
||||
| } until z
|
||||
| }
|
||||
? UnmeaningfulReadError: z in main
|
||||
|
||||
### copy ###
|
||||
|
||||
Can't `copy` from a memory location that isn't initialized.
|
||||
|
Loading…
x
Reference in New Issue
Block a user