git @ Cat's Eye Technologies SixtyPical / 76ec722
Add failing tests for gotos inside runtime-context-making blocks. Chris Pressey 3 years ago
1 changed file(s) with 78 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
20842084 | }
20852085 ? TypeMismatchError
20862086
2087 A `goto` cannot appear within a `save` block, even if it is otherwise in tail position.
2088
2089 | routine other
2090 | trashes a, z, n
2091 | {
2092 | ld a, 0
2093 | }
2094 |
2095 | routine main
2096 | trashes a, z, n
2097 | {
2098 | ld a, 1
2099 | save x {
2100 | ld x, 2
2101 | goto other
2102 | }
2103 | }
2104 ? IllegalJumpError
2105
2106 ### with interrupts ###
2107
2108 | vector routine
2109 | inputs x
2110 | outputs x
2111 | trashes z, n
2112 | bar
2113 |
2114 | routine foo
2115 | inputs x
2116 | outputs x
2117 | trashes z, n
2118 | {
2119 | inc x
2120 | }
2121 |
2122 | routine main
2123 | outputs bar
2124 | trashes a, n, z
2125 | {
2126 | with interrupts off {
2127 | copy foo, bar
2128 | }
2129 | }
2130 = ok
2131
2132 A `goto` cannot appear within a `with interrupts` block, even if it is
2133 otherwise in tail position.
2134
2135 | vector routine
2136 | inputs x
2137 | outputs x
2138 | trashes z, n
2139 | bar
2140 |
2141 | routine foo
2142 | inputs x
2143 | outputs x
2144 | trashes z, n
2145 | {
2146 | inc x
2147 | }
2148 |
2149 | routine other
2150 | trashes bar, a, n, z
2151 | {
2152 | ld a, 0
2153 | }
2154 |
2155 | routine main
2156 | trashes bar, a, n, z
2157 | {
2158 | with interrupts off {
2159 | copy foo, bar
2160 | goto other
2161 | }
2162 | }
2163 ? IllegalJumpError
2164
20872165 ### copy ###
20882166
20892167 Can't `copy` from a memory location that isn't initialized.