Skip to content

Commit 2d6b433

Browse files
Automated Resyntax fixes (#1398)
This is an automated change generated by Resyntax. #### Pass 1 Applied 2 fixes to [`typed-racket-lib/typed-racket/env/type-alias-helper.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/env/type-alias-helper.rkt) * Line 5, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 307, `inline-unnecessary-define`: This variable is returned immediately and can be inlined. Applied 1 fix to [`typed-racket-lib/typed-racket/env/signature-env.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/env/signature-env.rkt) * Line 13, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 5 fixes to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 32, `inline-unnecessary-define`: This variable is returned immediately and can be inlined. * Line 52, `always-throwing-if-to-when`: Using `when` and `unless` is simpler than a conditional with an always-throwing branch. * Line 61, `cond-let-to-cond-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 82, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. #### Pass 2 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. #### Pass 3 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. #### Pass 4 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. #### Pass 5 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. #### Pass 6 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. #### Pass 7 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. #### Pass 8 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. #### Pass 9 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. #### Pass 10 Applied 1 fix to [`typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt`](../blob/HEAD/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt) * Line 7, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. ## Summary Fixed 17 issues in 3 files. * Fixed 12 occurrences of `tidy-require` * Fixed 2 occurrences of `inline-unnecessary-define` * Fixed 1 occurrence of `always-throwing-if-to-when` * Fixed 1 occurrence of `cond-let-to-cond-define` * Fixed 1 occurrence of `let-to-define` Co-authored-by: resyntax-ci[bot] <181813515+resyntax-ci[bot]@users.noreply.github.com>
1 parent 42b8e1e commit 2d6b433

File tree

3 files changed

+80
-80
lines changed

3 files changed

+80
-80
lines changed

typed-racket-lib/typed-racket/env/signature-env.rkt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
signature-env-map
1111
signature-env-for-each)
1212

13-
(require syntax/private/id-table
13+
(require (for-syntax racket/base
14+
syntax/parse)
1415
racket/promise
15-
(for-syntax syntax/parse racket/base)
16-
"env-utils.rkt"
16+
syntax/private/id-table
17+
"../rep/type-rep.rkt"
1718
"../utils/tc-utils.rkt"
18-
"../rep/type-rep.rkt")
19+
"env-utils.rkt")
1920

2021
;; initial signature environment
2122
(define signature-env (make-free-id-table))

typed-racket-lib/typed-racket/env/type-alias-helper.rkt

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,31 @@
22

33
;; This module provides helper functions for type aliases
44

5-
(require "../utils/utils.rkt"
6-
"../utils/tarjan.rkt"
7-
"../utils/tc-utils.rkt"
8-
"type-alias-env.rkt"
9-
"type-name-env.rkt"
10-
"../rep/type-rep.rkt"
11-
"../rep/free-variance.rkt"
12-
"../rep/type-constr.rkt"
13-
"tvar-env.rkt"
14-
"type-constr-env.rkt"
15-
"../private/parse-type.rkt"
16-
"../private/user-defined-type-constr.rkt"
17-
"../typecheck/internal-forms.rkt"
18-
"../types/resolve.rkt"
19-
"../types/base-abbrev.rkt"
20-
"../types/substitute.rkt"
5+
(require (for-template racket/base
6+
"../typecheck/internal-forms.rkt")
7+
racket/dict
8+
racket/function
219
racket/list
2210
racket/match
2311
racket/set
24-
racket/dict
25-
racket/function
2612
syntax/id-table
2713
syntax/parse
28-
(for-template
29-
"../typecheck/internal-forms.rkt"
30-
racket/base))
14+
"../private/parse-type.rkt"
15+
"../private/user-defined-type-constr.rkt"
16+
"../rep/free-variance.rkt"
17+
"../rep/type-constr.rkt"
18+
"../rep/type-rep.rkt"
19+
"../typecheck/internal-forms.rkt"
20+
"../types/base-abbrev.rkt"
21+
"../types/resolve.rkt"
22+
"../types/substitute.rkt"
23+
"../utils/tarjan.rkt"
24+
"../utils/tc-utils.rkt"
25+
"../utils/utils.rkt"
26+
"tvar-env.rkt"
27+
"type-alias-env.rkt"
28+
"type-constr-env.rkt"
29+
"type-name-env.rkt")
3130

3231
(provide find-strongly-connected-type-aliases
3332
register-all-type-aliases
@@ -304,8 +303,7 @@
304303
(match-define (list id type-stx args) record)
305304
(define ty-op (parse-type-operator-abstraction id args type-stx
306305
(lambda (x)
307-
(define res (in-same-component? id x))
308-
res)
306+
(in-same-component? id x))
309307
type-alias-productivity-map
310308
#:delay-variances? #t
311309
#:recursive? #t))

typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
;; - fix datum-literals ?
55
;; - enable type-annotation test by upgrading user's annotations to trust codomain
66

7-
(require
8-
"../test-utils.rkt"
9-
rackunit
10-
racket/pretty
11-
racket/list
12-
racket/set
13-
syntax/parse
14-
(only-in racket/format ~a)
15-
(only-in syntax/modread with-module-reading-parameterization))
7+
(require racket/list
8+
racket/pretty
9+
racket/set
10+
rackunit
11+
syntax/parse
12+
(only-in racket/format ~a)
13+
(only-in syntax/modread with-module-reading-parameterization)
14+
"../test-utils.rkt")
1615

1716
(provide tests)
1817
(gen-test-main)
@@ -29,10 +28,8 @@
2928
(with-module-reading-parameterization
3029
(lambda ()
3130
(read-syntax (object-name in-port) in-port))))))
32-
(define stx
33-
(parameterize ((current-namespace (make-base-namespace)))
34-
(expand mod-stx)))
35-
stx)
31+
(parameterize ([current-namespace (make-base-namespace)])
32+
(expand mod-stx)))
3633

3734
;; ---
3835

@@ -49,20 +46,25 @@
4946

5047
(define (stx-find orig-stx p?)
5148
(define stx* (stx-find* orig-stx p?))
52-
(if (or (null? stx*)
53-
(not (null? (cdr stx*))))
54-
(raise-arguments-error 'stx-find "non-unique results" "num matches" (length stx*) "orig-stx" orig-stx "predicate" p? "matches" stx*)
55-
(car stx*)))
49+
(when (or (null? stx*) (not (null? (cdr stx*))))
50+
(raise-arguments-error 'stx-find
51+
"non-unique results"
52+
"num matches"
53+
(length stx*)
54+
"orig-stx"
55+
orig-stx
56+
"predicate"
57+
p?
58+
"matches"
59+
stx*))
60+
(car stx*))
5661

5762
(define (stx-find* orig-stx p?)
5863
(let loop ((stx orig-stx))
5964
(cond
6065
[(syntax? stx)
61-
(let ((v (p? stx)))
62-
(if v
63-
(list
64-
(if (eq? #true v) stx v))
65-
(loop (syntax-e stx))))]
66+
(define v (p? stx))
67+
(if v (list (if (eq? #true v) stx v)) (loop (syntax-e stx)))]
6668
[(pair? stx)
6769
(append (loop (car stx)) (loop (cdr stx)))]
6870
[else
@@ -79,37 +81,36 @@
7981
((~literal #%plain-app) (~datum shallow-shape-check) . _)))
8082

8183
(define (stx-find-define-predicate-ctc stx pred-name)
82-
(let* ((lift-id
83-
(stx-find stx
84-
(syntax-parser
85-
#:datum-literals (define-values let-values #%app)
86-
((define-values (name:id) (let-values (((:id) (#%app fcp:id lift:id))) _))
87-
#:when (eq? (syntax-e #'name) pred-name)
88-
#'lift)
89-
(_ #f))
90-
))
91-
(lift-ctc
92-
(stx-find stx
93-
(syntax-parser
94-
(((~datum define-values) (lt:id) ctc:id)
95-
#:when (eq? (syntax-e #'lt) (syntax-e lift-id))
96-
#'ctc)
97-
(_ #f))))
98-
(ctc*
99-
(stx-find* stx
100-
(syntax-parser
101-
#:datum-literals (define-values lambda)
102-
((define-values (g:id) (lambda (_) body))
103-
#:when (eq? (syntax-e #'g) (syntax-e lift-ctc))
104-
#'body)
105-
(_ #f)))))
106-
(cond
107-
[(null? ctc*)
108-
lift-ctc]
109-
[(null? (cdr ctc*))
110-
(car ctc*)]
111-
[else
112-
(raise-arguments-error 'stx-find-define-predicate-ctc "cannot find lifted" "pred" pred-name)])))
84+
(define lift-id
85+
(stx-find stx
86+
(syntax-parser
87+
#:datum-literals (define-values let-values #%app)
88+
[(define-values (name:id)
89+
(let-values ([(:id) (#%app fcp:id lift:id)])
90+
_))
91+
#:when (eq? (syntax-e #'name) pred-name)
92+
#'lift]
93+
[_ #f])))
94+
(define lift-ctc
95+
(stx-find stx
96+
(syntax-parser
97+
[((~datum define-values) (lt:id) ctc:id)
98+
#:when (eq? (syntax-e #'lt) (syntax-e lift-id))
99+
#'ctc]
100+
[_ #f])))
101+
(define ctc*
102+
(stx-find* stx
103+
(syntax-parser
104+
#:datum-literals (define-values lambda)
105+
[(define-values (g:id) (lambda (_) body))
106+
#:when (eq? (syntax-e #'g) (syntax-e lift-ctc))
107+
#'body]
108+
[_ #f])))
109+
(cond
110+
[(null? ctc*) lift-ctc]
111+
[(null? (cdr ctc*)) (car ctc*)]
112+
[else
113+
(raise-arguments-error 'stx-find-define-predicate-ctc "cannot find lifted" "pred" pred-name)]))
113114

114115
(define (split-shape-check stx)
115116
(define expr (->datum stx))

0 commit comments

Comments
 (0)