forked from alex-eg/sex
lower match to an if chain, so break in an arm leaves the loop
The switch it lowered to took a break in an arm for its own, and the loop around the match went on. With no else the last arm is the chain's else, which keeps C from warning that a function may return nothing.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
"nested: -(2 + 3) = -5"
|
||||
"size: 4"
|
||||
"tagged only: 1"
|
||||
"broke out after 2"
|
||||
"rows: 18 5")
|
||||
(return 0)
|
||||
|
||||
@@ -93,6 +94,17 @@
|
||||
((red ()) (printf "tagged only: 0\n"))
|
||||
((green ()) (printf "tagged only: 1\n")))
|
||||
|
||||
;; there is no switch in the source, so `break' in an arm leaves the
|
||||
;; loop around the match; one in a loop of the arm's own leaves that
|
||||
(var lights [light 3] #((light/green) (light/red) (light/green)))
|
||||
(var seen int 0)
|
||||
(for (var i int 0) (< i 3) (++ i)
|
||||
(++ seen)
|
||||
(match [lights i]
|
||||
((red ()) (while true (break)) (break))
|
||||
((green ()) (continue))))
|
||||
(printf "broke out after %d\n" seen)
|
||||
|
||||
(var a [int N] #(5 6 7 8))
|
||||
(var rows [row 2] #((row/cells a) (row/cells #(1 2 3 4))))
|
||||
(= [a 0] 50) ; the row holds a copy
|
||||
|
||||
Reference in New Issue
Block a user