|
407 | 407 | "expected single value, got multiple (or zero) values")])) |
408 | 408 |
|
409 | 409 |
|
| 410 | +(define (tc-expr-seq exps tc-expr |
| 411 | + [tail-expected (-tc-any-results #f)] |
| 412 | + #:unreachable-op [unreachable-op #f]) |
| 413 | + (define any-res (-tc-any-results #f)) |
| 414 | + (if (null? exps) |
| 415 | + (-tc-any-results -tt) |
| 416 | + (let loop ([exps exps]) |
| 417 | + (match exps |
| 418 | + [(list tail-exp) (tc-expr tail-exp tail-expected)] |
| 419 | + [(cons e rst) |
| 420 | + (define props |
| 421 | + (match (tc-expr e any-res) |
| 422 | + [(tc-any-results: p) (list p)] |
| 423 | + [(tc-results: tcrs _) |
| 424 | + (map (match-lambda |
| 425 | + [(tc-result: _ (PropSet: p+ p-) _) |
| 426 | + (-or p+ p-)]) |
| 427 | + tcrs)])) |
| 428 | + (with-lexical-env+props |
| 429 | + props |
| 430 | + #:expected any-res |
| 431 | + ;; If `e` is ill-typed and unreachable-op is supplied, call |
| 432 | + ;; unreachable-op. Otherwise, check the subsequent expressions |
| 433 | + #:unreachable (if unreachable-op |
| 434 | + (unreachable-op rst) |
| 435 | + (loop rst)) |
| 436 | + ;; Keep going with an environment extended with the |
| 437 | + ;; propositions that are true if execution reaches this |
| 438 | + ;; point. |
| 439 | + (loop rst))])))) |
| 440 | + |
410 | 441 | ;; tc-body/check: syntax? tc-results? -> tc-results? |
411 | 442 | ;; Body must be a non empty sequence of expressions to typecheck. |
412 | 443 | ;; The final one will be checked against expected. |
413 | 444 | (define (tc-body/check body expected) |
414 | | - (define any-res (-tc-any-results #f)) |
415 | | - (define exps (syntax->list body)) |
416 | | - (let loop ([exps exps]) |
417 | | - (match exps |
418 | | - [(list tail-exp) (tc-expr/check tail-exp expected)] |
419 | | - [(cons e rst) |
420 | | - (define results (tc-expr/check e any-res)) |
421 | | - (define props |
422 | | - (match results |
423 | | - [(tc-any-results: p) (list p)] |
424 | | - [(tc-results: tcrs _) |
425 | | - (map (match-lambda |
426 | | - [(tc-result: _ (PropSet: p+ p-) _) |
427 | | - (-or p+ p-)]) |
428 | | - tcrs)])) |
429 | | - (with-lexical-env+props |
430 | | - props |
431 | | - #:expected any-res |
432 | | - ;; If `e` bails out, mark the rest as ignored. |
433 | | - #:unreachable (for-each register-ignored! rst) |
434 | | - ;; Keep going with an environment extended with the |
435 | | - ;; propositions that are true if execution reaches this |
436 | | - ;; point. |
437 | | - (loop rst))]))) |
| 445 | + (tc-expr-seq (syntax->list body) |
| 446 | + tc-expr/check |
| 447 | + expected |
| 448 | + #:unreachable-op |
| 449 | + ;; the expr bails out, mark the rest as ignored |
| 450 | + (lambda (rst) (for-each register-ignored! rst)))) |
438 | 451 |
|
439 | 452 | ;; find-stx-type : Any [(or/c Type? #f)] -> Type? |
440 | 453 | ;; recursively find the type of either a syntax object or the result of syntax-e |
|
0 commit comments