|
306 | 306 | (map (lambda (x) (replace-vars x renames)) |
307 | 307 | (cdr e)))))) |
308 | 308 |
|
309 | | -(define (contains-thisfunction? expr) |
310 | | - (expr-contains-p (lambda (x) (and (pair? x) (eq? (car x) 'thisfunction))) expr)) |
311 | | - |
312 | 309 | (define (make-generator-function name sp-names arg-names body) |
313 | 310 | (let ((arg-names (append sp-names |
314 | 311 | (map (lambda (n) |
|
555 | 552 | (insert-after-meta `(block |
556 | 553 | ,@stmts) |
557 | 554 | (cons `(meta nkw ,(+ (length vars) (length restkw))) |
558 | | - (if (and name (contains-thisfunction? `(block ,@stmts))) |
| 555 | + (if (and name (has-thisfunction? `(block ,@stmts))) |
559 | 556 | (cons `(meta thisfunction-original ,name) annotations) |
560 | 557 | annotations))) |
561 | 558 | rett) |
|
2919 | 2916 | 'generator |
2920 | 2917 | (lambda (e) |
2921 | 2918 | (check-no-return e) |
| 2919 | + (check-no-thisfunction e) |
2922 | 2920 | (expand-generator e #f '())) |
2923 | 2921 |
|
2924 | 2922 | 'flatten |
|
3003 | 3001 | (if (has-return? e) |
3004 | 3002 | (error "\"return\" not allowed inside comprehension or generator"))) |
3005 | 3003 |
|
| 3004 | +(define (has-thisfunction? e) |
| 3005 | + (expr-contains-p thisfunction? e (lambda (x) (not (function-def? x))))) |
| 3006 | + |
| 3007 | +(define (check-no-thisfunction e) |
| 3008 | + (if (has-thisfunction? e) |
| 3009 | + (error "\"thisfunction\" not allowed inside comprehension or generator"))) |
| 3010 | + |
3006 | 3011 | (define (has-break-or-continue? e) |
3007 | 3012 | (expr-contains-p (lambda (x) (and (pair? x) (memq (car x) '(break continue)))) |
3008 | 3013 | e |
|
3011 | 3016 |
|
3012 | 3017 | (define (lower-comprehension ty expr itrs) |
3013 | 3018 | (check-no-return expr) |
| 3019 | + (check-no-thisfunction expr) |
3014 | 3020 | (if (has-break-or-continue? expr) |
3015 | 3021 | (error "break or continue outside loop")) |
3016 | 3022 | (let ((result (make-ssavalue)) |
|
0 commit comments