mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-09-28 17:54:39 +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
|
# it will always be executed at least once, so analyze it having
|
||||||
# been executed the first time.
|
# been executed the first time.
|
||||||
self.analyze_block(instr.block, context)
|
self.analyze_block(instr.block, context)
|
||||||
|
context.assert_meaningful(src)
|
||||||
|
|
||||||
# now analyze it having been executed a second time, with the context
|
# now analyze it having been executed a second time, with the context
|
||||||
# of it having already been executed.
|
# of it having already been executed.
|
||||||
self.analyze_block(instr.block, context)
|
self.analyze_block(instr.block, context)
|
||||||
|
context.assert_meaningful(src)
|
||||||
|
|
||||||
# NB I *think* that's enough... but it might not be?
|
|
||||||
elif opcode == 'copy':
|
elif opcode == 'copy':
|
||||||
# check that their types are basically compatible
|
# check that their types are basically compatible
|
||||||
if src.type == dest.type:
|
if src.type == dest.type:
|
||||||
|
@ -1017,6 +1017,23 @@ initialized at the start.
|
|||||||
| }
|
| }
|
||||||
? UnmeaningfulReadError: y in main
|
? 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 ###
|
### copy ###
|
||||||
|
|
||||||
Can't `copy` from a memory location that isn't initialized.
|
Can't `copy` from a memory location that isn't initialized.
|
||||||
|
Loading…
Reference in New Issue
Block a user