|
52 | 52 | [#`(! #,props ... #,body) |
53 | 53 | (check-properties* props '() error! deprecated-ops) |
54 | 54 | (loop body vars)] |
| 55 | + [#`(cast #,arg) (loop arg vars)] |
| 56 | + [#`(cast #,args ...) |
| 57 | + (error! stx "Invalid `cast` expression with ~a arguments (expects 1)" (length args)) |
| 58 | + (unless (null? args) |
| 59 | + (loop (first args) vars))] |
55 | 60 | [#`(,(? (curry set-member? '(+ * and or))) #,args ...) |
56 | 61 | ;; Variary (minimum 0 arguments) |
57 | 62 | (for ([arg args]) |
|
152 | 157 | (define (check-program* stx vars props body error!) |
153 | 158 | (unless (list? vars) |
154 | 159 | (error! stx "Invalid arguments list ~a; must be a list" stx)) |
155 | | - (define vars* (filter identifier? vars)) |
156 | | - (when (list? vars) |
157 | | - (for ([var vars] |
158 | | - #:unless (identifier? var)) |
159 | | - (error! stx "Argument ~a is not a variable name" var)) |
160 | | - (when (check-duplicate-identifier vars*) |
161 | | - (error! stx "Duplicate argument name ~a" (check-duplicate-identifier vars*)))) |
162 | 160 | (define deprecated-ops (mutable-set)) |
| 161 | + (define vars* |
| 162 | + (reap [sow] |
| 163 | + (when (list? vars) |
| 164 | + (for ([var (in-list vars)]) |
| 165 | + (match var |
| 166 | + [(? identifier? x) (sow var)] |
| 167 | + [#`(! #,props ... #,name) |
| 168 | + (check-properties* props (immutable-bound-id-set '()) error! deprecated-ops) |
| 169 | + (cond |
| 170 | + [(identifier? name) (sow name)] |
| 171 | + [else (error! var "Annotated argument ~a is not a variable name" name)])]))))) |
| 172 | + (when (check-duplicate-identifier vars*) |
| 173 | + (error! stx "Duplicate argument name ~a" (check-duplicate-identifier vars*))) |
163 | 174 | (check-properties* props (immutable-bound-id-set vars*) error! deprecated-ops) |
164 | 175 | (check-expression* body (immutable-bound-id-set vars*) error! deprecated-ops) |
165 | 176 | (for ([op (in-set deprecated-ops)]) |
|
0 commit comments