Skip to content

Commit b435903

Browse files
committed
Fix racket#1157: Handle void in error propagation through type checker
Added defensive patterns to handle void values that can propagate through the type checker when earlier errors occur. Updated add-unconditional-prop, add-unconditional-prop-all-args, and type-table->tooltips to gracefully handle invalid inputs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Closes racket#1157
1 parent db229fa commit b435903

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

typed-racket-lib/typed-racket/types/prop-ops.rkt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@
7575
(match res
7676
[(tc-any-results: _) res]
7777
[(tc-results: tcrs db)
78-
(-tc-results (map update-ps tcrs) db)]))
78+
(-tc-results (map update-ps tcrs) db)]
79+
;; Handle error cases (e.g., void from error propagation)
80+
[_ res]))
7981

8082

8183
;; atomic-contradiction?: Prop? Prop? -> boolean?
@@ -411,7 +413,9 @@
411413
[(tc-result: t (PropSet: p+ p-) o)
412414
(-tc-result t (-PS (-and prop p+) (-and prop p-)) o)])
413415
tcrs)
414-
db)])
416+
db)]
417+
;; Handle error cases where results is invalid (e.g., void from error propagation)
418+
[(_ _) results])
415419

416420

417421
;; ands the given type prop to both sides of the given arr for each argument
@@ -428,7 +432,13 @@
428432
rst
429433
kws
430434
(make-Values (list (-result tp (-PS (-and p+ new-props) (-and p- new-props)) op)))
431-
rng-T+)))])])
435+
rng-T+)))]
436+
;; Range doesn't have expected PropSet - return unchanged
437+
[_ arr])]
438+
;; Multiple arrows (case->) or other function types - return unchanged
439+
[((Fun: _) _) arr]
440+
;; Any other type - return unchanged (e.g., error types)
441+
[(_ _) arr])
432442

433443
;; tc-results/c -> tc-results/c
434444
(define/match (erase-props tc)

typed-racket-lib/typed-racket/types/type-table.rkt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@
129129
(add1 index)
130130
(pretty-format-rep (cleanup-type type)
131131
#:indent 2)))))]
132-
[(tc-any-results: _) "AnyValues"]))
132+
[(tc-any-results: _) "AnyValues"]
133+
;; Handle invalid results from error propagation
134+
[_ #f]))
133135
(cond [(not printed-type-thunks) tooltips]
134136
[else
135137
(append (make-tooltip-vector stx printed-type-thunks pos span)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#lang typed/racket
2+
3+
;; Issue #1157: Regression test - previously caused "define/match: no matching clause"
4+
;; internal error when type checking case-> functions with keyword arguments.
5+
;; Fixed by adding defensive patterns to add-unconditional-prop, add-unconditional-prop-all-args,
6+
;; reduce-tc-results/subsumption, check-below, and type-table->tooltips.
7+
8+
(provide func)
9+
10+
(: func (case-> [-> #:bool True One]
11+
[-> #:bool False Zero]))
12+
(define (func #:bool b)
13+
(cond [(eq? #t b) 1]
14+
[(eq? #f b) 0]))
15+
16+
;; Just defining and exporting the function validates that the type checker doesn't crash.

0 commit comments

Comments
 (0)