Skip to content

Commit b983387

Browse files
Automated Resyntax fixes
This is an automated change generated by Resyntax. WARNING: Missing test for base type 'Positive-Single-Flonum' WARNING: Missing test for base type '∪' WARNING: Missing test for base type 'Single-Flonum' WARNING: Missing test for base type 'Intersection' WARNING: Missing test for base type 'Inexact-Imaginary' WARNING: Missing test for base type 'Single-Flonum-Complex' WARNING: Missing test for base type 'Union' WARNING: Missing test for base type 'Single-Flonum-Zero' WARNING: Missing test for base type 'ExtFlVector' WARNING: Missing test for base type '∩' WARNING: Missing test for base type 'ExtFlonum-Positive-Zero' WARNING: Missing test for base type 'Nonpositive-ExtFlonum' WARNING: Missing test for base type 'Place' WARNING: Missing test for base type 'U' WARNING: Missing test for base type 'ExtFlonum-Zero' WARNING: Missing test for base type 'Internal-Definition-Context' WARNING: Missing test for base type 'Read-Table' WARNING: Missing test for base type 'Un' WARNING: Missing test for base type 'Negative-Single-Flonum' WARNING: Missing test for base type 'Unquoted-Printing-String' WARNING: Missing test for base type 'Negative-ExtFlonum' WARNING: Missing test for base type 'Single-Flonum-Negative-Zero' WARNING: Missing test for base type 'Single-Flonum-Positive-Zero' WARNING: Missing test for base type 'ExtFlonum' WARNING: Missing test for base type 'Nonnegative-Single-Flonum' WARNING: Missing test for base type 'ExtFlonum-Nan' WARNING: Missing test for base type 'ExtFlonum-Negative-Zero' WARNING: Missing test for base type 'Single-Flonum-Nan' WARNING: Missing test for base type 'Positive-ExtFlonum' WARNING: Missing test for base type 'Nonnegative-ExtFlonum' WARNING: Missing test for base type 'Nonpositive-Single-Flonum' #### Pass 1 Applied 1 fix to [`typed-racket-lib/typed-racket/typecheck/tc-expression.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/tc-expression.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 4 fixes to [`typed-racket-lib/typed-racket/typed-reader.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typed-reader.rkt) * Line 11, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 25, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 35, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 68, `case-lambda-with-single-case-to-lambda`: This `case-lambda` form only has one case. Use a regular lambda instead. Applied 2 fixes to [`typed-racket-lib/typed-racket/typecheck/renamer.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/renamer.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 46, `if-let-to-cond`: `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting Applied 9 fixes to [`typed-racket-lib/typed-racket/typecheck/integer-refinements.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/integer-refinements.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 74, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 89, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 118, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 133, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 150, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 164, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 177, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 199, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. Applied 7 fixes to [`typed-racket-lib/typed-racket/logic/ineq.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/logic/ineq.rkt) * Line 101, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 214, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 335, `define-lambda-to-define`: The `define` form supports a shorthand for defining functions. * Line 490, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 603, `let-values-then-call-to-call-with-values`: This `let-values` expression can be replaced with a simpler, equivalent `call-with-values` expression. * Line 612, `let-values-then-call-to-call-with-values`: This `let-values` expression can be replaced with a simpler, equivalent `call-with-values` expression. * Line 624, `let-values-then-call-to-call-with-values`: This `let-values` expression can be replaced with a simpler, equivalent `call-with-values` expression. Applied 1 fix to [`typed-racket-lib/typed-racket/typecheck/typechecker.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/typechecker.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/typecheck/possible-domains.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/possible-domains.rkt) * Line 58, `and-match-to-match`: This `and` expression can be turned into a clause of the inner `match` expression, reducing nesting. Applied 2 fixes to [`typed-racket-lib/typed-racket/typecheck/tc-funapp.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/tc-funapp.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 134, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. Applied 1 fix to [`typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt) * Line 197, `format-identity`: This use of `format` does nothing. Applied 1 fix to [`typed-racket-more/typed/racket/gui.rkt`](../blob/HEAD/typed-racket-more/typed/racket/gui.rkt) * Line 5, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 2 fixes to [`typed-racket-lib/typed-racket/typecheck/tc-literal.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/tc-literal.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 193, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 1 fix to [`typed-racket-lib/typed-racket/typecheck/tc-envops.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/tc-envops.rkt) * Line 45, `if-x-else-x-to-and`: This conditional expression can be replaced with a simpler, equivalent expression. Applied 2 fixes to [`typed-racket-lib/typed-racket/tc-setup.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/tc-setup.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 39, `if-begin-to-cond`: Using `cond` instead of `if` here makes `begin` unnecessary Applied 1 fix to [`typed-racket-test/succeed/shallow/type-printer-single-level.rkt`](../blob/HEAD/typed-racket-test/succeed/shallow/type-printer-single-level.rkt) * Line 6, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 6 fixes to [`typed-racket-lib/typed-racket/typecheck/tc-structs.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/tc-structs.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 196, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 416, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 460, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 465, `single-clause-match-to-match-define`: This `match` expression can be simplified using `match-define`. * Line 516, `map-to-for`: This `map` operation can be replaced with a `for/list` loop. Applied 1 fix to [`typed-racket-lib/typed-racket/typecheck/error-message.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/error-message.rkt) * Line 80, `inverted-when`: This negated `when` expression can be replaced by an `unless` expression. Applied 2 fixes to [`typed-racket-lib/typed-racket/core.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/core.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 51, `inverted-when`: This negated `when` expression can be replaced by an `unless` expression. #### Pass 2 Applied 2 fixes to [`typed-racket-lib/typed-racket/typed-reader.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typed-reader.rkt) * Line 14, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 27, `cond-let-to-cond-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 2 fixes to [`typed-racket-lib/typed-racket/typecheck/error-message.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/typecheck/error-message.rkt) * Line 83, `format-identity`: This use of `format` does nothing. * Line 85, `format-identity`: This use of `format` does nothing. ## Summary Fixed 48 issues in 17 files. * Fixed 11 occurrences of `tidy-require` * Fixed 9 occurrences of `define-lambda-to-define` * Fixed 7 occurrences of `let-to-define` * Fixed 6 occurrences of `single-clause-match-to-match-define` * Fixed 3 occurrences of `let-values-then-call-to-call-with-values` * Fixed 3 occurrences of `format-identity` * Fixed 2 occurrences of `inverted-when` * Fixed 1 occurrence of `and-match-to-match` * Fixed 1 occurrence of `case-lambda-with-single-case-to-lambda` * Fixed 1 occurrence of `cond-let-to-cond-define` * Fixed 1 occurrence of `if-let-to-cond` * Fixed 1 occurrence of `if-begin-to-cond` * Fixed 1 occurrence of `map-to-for` * Fixed 1 occurrence of `if-x-else-x-to-and`
1 parent 81cd9a8 commit b983387

File tree

17 files changed

+442
-437
lines changed

17 files changed

+442
-437
lines changed

typed-racket-lib/typed-racket/core.rkt

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
#lang racket/base
22

3-
(require (rename-in "utils/utils.rkt")
4-
(for-syntax racket/base)
5-
(for-template racket/base)
6-
"private/with-types.rkt"
7-
"private/type-contract.rkt"
8-
(except-in syntax/parse id)
9-
racket/match racket/syntax
3+
(require (for-syntax racket/base)
4+
(for-template racket/base
5+
"base-env/top-interaction.rkt")
6+
racket/match
7+
racket/syntax
108
syntax/flatten-begin
11-
"types/utils.rkt"
12-
"types/abbrev.rkt"
13-
"types/generalize.rkt"
9+
(rename-in "utils/utils.rkt")
10+
(except-in syntax/parse id)
11+
"private/type-contract.rkt"
12+
"private/with-types.rkt"
13+
"rep/type-rep.rkt"
14+
"standard-inits.rkt"
15+
"tc-setup.rkt"
1416
"typecheck/provide-handling.rkt"
1517
"typecheck/tc-app-helper.rkt"
16-
"rep/type-rep.rkt"
17-
(for-template "base-env/top-interaction.rkt")
18-
"utils/utils.rkt"
19-
"utils/tc-utils.rkt"
18+
"types/abbrev.rkt"
19+
"types/generalize.rkt"
20+
"types/utils.rkt"
2021
"utils/arm.rkt"
21-
"standard-inits.rkt"
22-
"tc-setup.rkt")
22+
"utils/tc-utils.rkt"
23+
"utils/utils.rkt")
2324

2425
(provide mb-core ti-core wt-core wt-core-shallow wt-core-optional)
2526

@@ -48,10 +49,12 @@
4849
(and (attribute opt?) (syntax-e (attribute opt?))))]
4950
[with-refinements? (and (or (attribute refinement-reasoning?)
5051
(with-refinements?))
51-
(when (not (eq? te-mode deep))
52+
(unless (eq? te-mode deep)
5253
(raise-arguments-error
53-
(string->symbol (format "typed/racket/~a" (keyword->string (syntax-e te-attr))))
54-
"#:with-refinements unsupported")))])
54+
(string->symbol (format "typed/racket/~a"
55+
(keyword->string
56+
(syntax-e te-attr))))
57+
"#:with-refinements unsupported")))])
5558
(tc-module/full te-mode stx pmb-form
5659
(λ (new-mod pre-before-code pre-after-code)
5760
(define ctc-cache (make-hash))

typed-racket-lib/typed-racket/logic/ineq.rkt

Lines changed: 41 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@
9999

100100
;; Leq to the internal leq rep
101101
(define (Leq->leq l)
102-
(match l
103-
[(LeqProp: (LExp: c1 ts1) (LExp: c2 ts2))
104-
(leq (lexp c1 ts1) (lexp c2 ts2))]))
102+
(match-define (LeqProp: (LExp: c1 ts1) (LExp: c2 ts2)) l)
103+
(leq (lexp c1 ts1) (lexp c2 ts2)))
105104

106105

107106
;; *****************************************************************************
@@ -215,10 +214,8 @@
215214
[(eqv? a 0) (lexp 0 (make-terms))]
216215
[(= a 1) exp]
217216
[else
218-
(match exp
219-
[(lexp: c h)
220-
(lexp (* c a)
221-
(terms-scale h a))])]))
217+
(match-define (lexp: c h) exp)
218+
(lexp (* c a) (terms-scale h a))]))
222219

223220
(module+ test
224221
(check-equal? (lexp-set (lexp* 17 '(42 x)) 'x 0)
@@ -332,13 +329,15 @@
332329
(-> lexp? (-> any/c any/c) string?)
333330
(define vars (terms-vars (lexp-vars e)))
334331
(define const (lexp-const e))
335-
(define term->string
336-
(λ (x) (string-append (if (= 1 (lexp-coeff e x))
337-
""
338-
(number->string (lexp-coeff e x)))
339-
"(" (if pp
340-
(pp x)
341-
(~a x)) ")")))
332+
(define (term->string x)
333+
(string-append (if (= 1 (lexp-coeff e x))
334+
""
335+
(number->string (lexp-coeff e x)))
336+
"("
337+
(if pp
338+
(pp x)
339+
(~a x))
340+
")"))
342341
(cond
343342
[(terms-empty? vars) (number->string const)]
344343
[(zero? const)
@@ -487,21 +486,18 @@
487486
;; leq2: ... + cx + .... <= ... + dx + ...
488487
(let-values ([(l1 r1) (leq-lexps leq1)]
489488
[(l2 r2) (leq-lexps leq2)])
490-
(let ([a (lexp-coeff l1 x)] [b (lexp-coeff r1 x)]
491-
[c (lexp-coeff l2 x)] [d (lexp-coeff r2 x)])
492-
(cond
493-
;; leq1: ax <= lexp1
494-
;; leq2: lexp2 <= dx
495-
[(and (eqv? 0 b) (eqv? 0 c))
496-
(leq (lexp-scale l2 a)
497-
(lexp-scale r1 d))]
498-
;; leq1: lexp1 <= bx
499-
;; leq2: cx <= lexp2
500-
[(and (eqv? 0 a) (eqv? 0 d))
501-
(leq (lexp-scale l1 c)
502-
(lexp-scale r2 b))]
503-
[else
504-
(error 'leq-join "cannot join ~a and ~a by ~a" leq1 leq2 x)]))))
489+
(define a (lexp-coeff l1 x))
490+
(define b (lexp-coeff r1 x))
491+
(define c (lexp-coeff l2 x))
492+
(define d (lexp-coeff r2 x))
493+
(cond
494+
;; leq1: ax <= lexp1
495+
;; leq2: lexp2 <= dx
496+
[(and (eqv? 0 b) (eqv? 0 c)) (leq (lexp-scale l2 a) (lexp-scale r1 d))]
497+
;; leq1: lexp1 <= bx
498+
;; leq2: cx <= lexp2
499+
[(and (eqv? 0 a) (eqv? 0 d)) (leq (lexp-scale l1 c) (lexp-scale r2 b))]
500+
[else (error 'leq-join "cannot join ~a and ~a by ~a" leq1 leq2 x)])))
505501

506502
(module+ test
507503
(check-equal? (leq-join (leq (lexp* '(2 x))
@@ -600,36 +596,31 @@
600596
(values xlhs xrhs (cons ineq nox))]))))
601597

602598
(module+ test
603-
(check-equal? (let-values ([(lt gt no)
604-
(sli-partition (list (leq (lexp* '(2 x) '(4 y) 1)
605-
(lexp* '(2 y))))
606-
'x)])
607-
(list lt gt no))
599+
(check-equal? (call-with-values
600+
(λ () (sli-partition (list (leq (lexp* '(2 x) '(4 y) 1) (lexp* '(2 y)))) 'x))
601+
list)
608602
(list (list (leq (lexp* '(2 x))
609603
(lexp* '(-2 y) -1)))
610604
(list)
611605
(list)))
612-
(check-equal? (let-values ([(lt gt no)
613-
(sli-partition (list (leq (lexp* '(2 x) '(4 y) 1)
614-
(lexp* '(2 y)))
615-
(leq (lexp* '(2 x) '(4 y))
616-
(lexp* '(2 y) '(42 x))))
617-
'x)])
618-
(list lt gt no))
606+
(check-equal? (call-with-values (λ ()
607+
(sli-partition (list (leq (lexp* '(2 x) '(4 y) 1) (lexp* '(2 y)))
608+
(leq (lexp* '(2 x) '(4 y))
609+
(lexp* '(2 y) '(42 x))))
610+
'x))
611+
list)
619612
(list (list (leq (lexp* '(2 x))
620613
(lexp* '(-2 y) -1)))
621614
(list (leq (lexp* '(2 y))
622615
(lexp* '(40 x))))
623616
(list)))
624-
(check-equal? (let-values ([(lt gt no)
625-
(sli-partition (list (leq (lexp* '(2 x) '(4 y) -1)
626-
(lexp* '(2 y)))
627-
(leq (lexp* '(2 x) '(4 y))
628-
(lexp* '(2 y) '(42 x)))
629-
(leq (lexp* '(2 z) '(4 y))
630-
(lexp* '(2 y) '(42 q))))
631-
'x)])
632-
(list lt gt no))
617+
(check-equal? (call-with-values
618+
(λ ()
619+
(sli-partition (list (leq (lexp* '(2 x) '(4 y) -1) (lexp* '(2 y)))
620+
(leq (lexp* '(2 x) '(4 y)) (lexp* '(2 y) '(42 x)))
621+
(leq (lexp* '(2 z) '(4 y)) (lexp* '(2 y) '(42 q))))
622+
'x))
623+
list)
633624
(list (list (leq (lexp* '(2 x))
634625
(lexp* '(-2 y) 1)))
635626
(list (leq (lexp* '(2 y))

typed-racket-lib/typed-racket/tc-setup.rkt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
#lang racket/base
22

3-
(require "utils/utils.rkt"
3+
(require (for-syntax racket/base)
4+
(for-template racket/base)
5+
racket/lazy-require
6+
racket/pretty
7+
racket/promise
48
syntax/kerncase
59
syntax/stx
6-
racket/pretty racket/promise racket/lazy-require
7-
"env/type-name-env.rkt"
8-
"env/type-alias-env.rkt"
910
"env/mvar-env.rkt"
10-
"utils/tc-utils.rkt"
11+
"env/type-alias-env.rkt"
12+
"env/type-name-env.rkt"
13+
"standard-inits.rkt"
1114
"utils/disarm.rkt"
12-
"utils/mutated-vars.rkt"
1315
"utils/lift.rkt"
14-
"standard-inits.rkt"
15-
(for-syntax racket/base)
16-
(for-template racket/base))
16+
"utils/mutated-vars.rkt"
17+
"utils/tc-utils.rkt"
18+
"utils/utils.rkt")
1719
(lazy-require [typed-racket/optimizer/optimizer (optimize-top)])
1820
(lazy-require [typed-racket/private/shallow-rewrite (shallow-rewrite-top)])
1921
(lazy-require [typed-racket/typecheck/tc-toplevel (tc-module)])
@@ -36,15 +38,15 @@
3638
;; types are enforced (not no-check etc.),
3739
;; PLT_TR_NO_OPTIMIZE is not set, and the
3840
;; current code inspector has sufficient privileges
39-
(if (and (optimize?)
40-
(memq (current-type-enforcement-mode) (list deep shallow))
41-
(not (getenv "PLT_TR_NO_OPTIMIZE"))
42-
(authorized-code-inspector?))
43-
(begin
44-
(do-time "Starting optimizer")
45-
(begin0 (stx-map optimize-top body)
46-
(do-time "Optimized")))
47-
body))
41+
(cond
42+
[(and (optimize?)
43+
(memq (current-type-enforcement-mode) (list deep shallow))
44+
(not (getenv "PLT_TR_NO_OPTIMIZE"))
45+
(authorized-code-inspector?))
46+
(do-time "Starting optimizer")
47+
(begin0 (stx-map optimize-top body)
48+
(do-time "Optimized"))]
49+
[else body]))
4850

4951
(define (maybe-shallow-rewrite body-stx ctc-cache)
5052
(case (current-type-enforcement-mode)

typed-racket-lib/typed-racket/typecheck/error-message.rkt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@
7777
(define class/object (if object? "object" "class"))
7878
(match-define (Class: row inits fields methods augments init-rest) c1)
7979
(match-define (Class: row* inits* fields* methods* augments* init-rest*) c2)
80-
(when (not object?)
80+
(unless object?
8181
(when (and (F? row) (not (F? row*)))
8282
(type-mismatch (format "Class with row variable `~a'" row)
83-
(format "Class with no row variable")))
83+
"Class with no row variable"))
8484
(when (and (F? row*) (not (F? row)))
85-
(type-mismatch (format "Class with no row variable")
85+
(type-mismatch "Class with no row variable"
8686
(format "Class with row variable `~a'" row*)))
8787
(when (and (F? row) (F? row) (not (equal? row row*)))
8888
(type-mismatch (format "Class with row variable `~a'" row)

0 commit comments

Comments
 (0)