Skip to content

Commit 00e65ec

Browse files
Fix 5 occurrences of let-to-define
Internal definitions are recommended instead of `let` expressions, to reduce nesting.
1 parent cf5dcb9 commit 00e65ec

File tree

5 files changed

+39
-31
lines changed

5 files changed

+39
-31
lines changed

typed-racket-lib/typed-racket/infer/infer-unit.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@
915915
[(? variance:const?) S]
916916
[(? variance:co?) S]
917917
[(? variance:contra?) T]
918-
[(? variance:inv?) (let ([gS (generalize S)]) (if (subtype gS T) gS S))]))
918+
[(? variance:inv?) (define gS (generalize S))
919+
(if (subtype gS T) gS S)]))
919920

920921
;; Since we don't add entries to the empty cset for index variables (since there is no
921922
;; widest constraint, due to dcon-exacts), we must add substitutions here if no constraint

typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -328,23 +328,31 @@
328328
msg-rngs)
329329
...))
330330
_))
331-
(let ([fcn-string (name->function-str name)])
332-
(if (and (andmap null? msg-doms)
333-
(null? argtypes))
334-
(tc-error/expr (string-append
335-
"Could not infer types for applying polymorphic "
331+
(define fcn-string (name->function-str name))
332+
(if (and (andmap null? msg-doms) (null? argtypes))
333+
(tc-error/expr
334+
(string-append "Could not infer types for applying polymorphic " fcn-string "\n"))
335+
(domain-mismatches
336+
f-stx
337+
args-stx
338+
t
339+
msg-doms
340+
msg-rests
341+
msg-rngs
342+
argtypes
343+
#f
344+
#f
345+
#:expected expected
346+
#:msg-thunk
347+
(lambda (dom)
348+
(string-append "Polymorphic "
336349
fcn-string
337-
"\n"))
338-
(domain-mismatches f-stx args-stx t msg-doms msg-rests
339-
msg-rngs argtypes #f #f #:expected expected
340-
#:msg-thunk (lambda (dom)
341-
(string-append
342-
"Polymorphic " fcn-string " could not be applied to arguments:\n"
343-
dom
344-
(if (not (subset? (apply set-union (seteq) (map fv/list msg-doms))
345-
(list->seteq msg-vars)))
346-
(string-append "Type Variables: " (stringify msg-vars) "\n")
347-
""))))))]
350+
" could not be applied to arguments:\n"
351+
dom
352+
(if (not (subset? (apply set-union (seteq) (map fv/list msg-doms))
353+
(list->seteq msg-vars)))
354+
(string-append "Type Variables: " (stringify msg-vars) "\n")
355+
"")))))]
348356
[(Poly-names:
349357
msg-vars
350358
(DepFun: raw-domain _ raw-rng))

typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@
143143
(dynamic-wind
144144
(λ () (save-errors!))
145145
(λ ()
146-
(let ([result (tc-expr/check form expected)])
147-
(and (not (current-type-error?)) result)))
146+
(define result (tc-expr/check form expected))
147+
(and (not (current-type-error?)) result))
148148
(λ () (restore-errors!))))))
149149

150150
(define (tc-expr/check/t? form expected)

typed-racket-lib/typed-racket/typecheck/tc-literal.rkt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@
184184
(define value->HT
185185
(case-lambda
186186
[(check-element h tycon expected-kt expected-vt)
187-
(let* ([kts (hash-map h (lambda (x y) (check-element x expected-kt)))]
188-
[vts (hash-map h (lambda (x y) (check-element y expected-vt)))]
189-
[kt (apply Un kts)]
190-
[vt (apply Un vts)])
191-
(tycon (check-below kt expected-kt) (check-below vt expected-vt)))]
187+
(define kts (hash-map h (lambda (x y) (check-element x expected-kt))))
188+
(define vts (hash-map h (lambda (x y) (check-element y expected-vt))))
189+
(define kt (apply Un kts))
190+
(define vt (apply Un vts))
191+
(tycon (check-below kt expected-kt) (check-below vt expected-vt))]
192192
[(check-element h tycon)
193193
(define kt (generalize (apply Un (map check-element (hash-keys h)))))
194194
(define vt (generalize (apply Un (map check-element (hash-values h)))))

typed-racket-test/unit-tests/static-contract-optimizer-tests.rkt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,12 @@
3232
(make-check-info 'trusted trusted-side)
3333
(make-check-expected expected))
3434
(λ ()
35-
(let ([opt (optimize argument
36-
#:trusted-positive trusted-positive
37-
#:trusted-negative trusted-negative)])
38-
(with-check-info* (list (make-check-actual opt))
39-
(lambda ()
40-
(unless (equal? opt expected)
41-
(fail-check))))))))
35+
(define opt
36+
(optimize argument #:trusted-positive trusted-positive #:trusted-negative trusted-negative))
37+
(with-check-info* (list (make-check-actual opt))
38+
(lambda ()
39+
(unless (equal? opt expected)
40+
(fail-check)))))))
4241

4342
(define-syntax (check-syntax stx)
4443
(syntax-parse stx

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy