reject a for whose header is grouped
C's parens carried over, ((var i int 0) (< i 4) (++ i)), left the writer short of slots, and it died in caddr with no location; with a long enough body it would have compiled the body into the header. Fixes #42.
This commit is contained in:
@@ -309,6 +309,22 @@ whitespace aside, THEN?"
|
||||
|
||||
;; A nested pointer chain used to silently lose a level:
|
||||
;; (var p (* (* char))) emitted `char *p'
|
||||
;; A grouped header, C's parens carried over, died in the writer with
|
||||
;; `(caddr) bad argument type' and no location
|
||||
(test-group "malformed for"
|
||||
(test-assert "a grouped header is named"
|
||||
(reports? (in-fn "(for ((var i int 0) (< i 4) (++ i)) (g i))")
|
||||
"header is not grouped"))
|
||||
(test-assert "even when the body fills the slots it left"
|
||||
(reports? (in-fn "(for ((var i int 0) (< i 4) (++ i)) (g i) (g i) (g i))")
|
||||
"header is not grouped"))
|
||||
(test-assert "a short one gets the shape"
|
||||
(reports? (in-fn "(for (var i int 0) (< i 4))")
|
||||
"(for init test step body ...)"))
|
||||
(test-assert "and both name the line"
|
||||
(reports? "(fn f () void\n (for ((var i int 0) (< i 4) (++ i)) (g i)))"
|
||||
"codegen.sex:2:")))
|
||||
|
||||
(test-group "malformed types are rejected"
|
||||
(test-assert "nested pointer chain"
|
||||
(reports? (in-fn "(var p (* (* char)))") "pointer chains are written flat"))
|
||||
|
||||
Reference in New Issue
Block a user