From 3546d2a54b9c44dbc5afe3160201811ad8667298 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 00:22:36 +0000 Subject: [PATCH] Automated Resyntax fixes 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` --- .../typed-racket/env/signature-env.rkt | 9 +- .../typed-racket/env/type-alias-helper.rkt | 44 ++++--- .../shallow-rewrite-expansion/main.rkt | 107 +++++++++--------- 3 files changed, 80 insertions(+), 80 deletions(-) diff --git a/typed-racket-lib/typed-racket/env/signature-env.rkt b/typed-racket-lib/typed-racket/env/signature-env.rkt index 112a92de7..cdd0ed549 100644 --- a/typed-racket-lib/typed-racket/env/signature-env.rkt +++ b/typed-racket-lib/typed-racket/env/signature-env.rkt @@ -10,12 +10,13 @@ signature-env-map signature-env-for-each) -(require syntax/private/id-table +(require (for-syntax racket/base + syntax/parse) racket/promise - (for-syntax syntax/parse racket/base) - "env-utils.rkt" + syntax/private/id-table + "../rep/type-rep.rkt" "../utils/tc-utils.rkt" - "../rep/type-rep.rkt") + "env-utils.rkt") ;; initial signature environment (define signature-env (make-free-id-table)) diff --git a/typed-racket-lib/typed-racket/env/type-alias-helper.rkt b/typed-racket-lib/typed-racket/env/type-alias-helper.rkt index 386c2e253..c67071101 100644 --- a/typed-racket-lib/typed-racket/env/type-alias-helper.rkt +++ b/typed-racket-lib/typed-racket/env/type-alias-helper.rkt @@ -2,32 +2,31 @@ ;; This module provides helper functions for type aliases -(require "../utils/utils.rkt" - "../utils/tarjan.rkt" - "../utils/tc-utils.rkt" - "type-alias-env.rkt" - "type-name-env.rkt" - "../rep/type-rep.rkt" - "../rep/free-variance.rkt" - "../rep/type-constr.rkt" - "tvar-env.rkt" - "type-constr-env.rkt" - "../private/parse-type.rkt" - "../private/user-defined-type-constr.rkt" - "../typecheck/internal-forms.rkt" - "../types/resolve.rkt" - "../types/base-abbrev.rkt" - "../types/substitute.rkt" +(require (for-template racket/base + "../typecheck/internal-forms.rkt") + racket/dict + racket/function racket/list racket/match racket/set - racket/dict - racket/function syntax/id-table syntax/parse - (for-template - "../typecheck/internal-forms.rkt" - racket/base)) + "../private/parse-type.rkt" + "../private/user-defined-type-constr.rkt" + "../rep/free-variance.rkt" + "../rep/type-constr.rkt" + "../rep/type-rep.rkt" + "../typecheck/internal-forms.rkt" + "../types/base-abbrev.rkt" + "../types/resolve.rkt" + "../types/substitute.rkt" + "../utils/tarjan.rkt" + "../utils/tc-utils.rkt" + "../utils/utils.rkt" + "tvar-env.rkt" + "type-alias-env.rkt" + "type-constr-env.rkt" + "type-name-env.rkt") (provide find-strongly-connected-type-aliases register-all-type-aliases @@ -304,8 +303,7 @@ (match-define (list id type-stx args) record) (define ty-op (parse-type-operator-abstraction id args type-stx (lambda (x) - (define res (in-same-component? id x)) - res) + (in-same-component? id x)) type-alias-productivity-map #:delay-variances? #t #:recursive? #t)) diff --git a/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt b/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt index 6686a5eaa..45462fc61 100644 --- a/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt +++ b/typed-racket-test/unit-tests/shallow-rewrite-expansion/main.rkt @@ -4,15 +4,14 @@ ;; - fix datum-literals ? ;; - enable type-annotation test by upgrading user's annotations to trust codomain -(require - "../test-utils.rkt" - rackunit - racket/pretty - racket/list - racket/set - syntax/parse - (only-in racket/format ~a) - (only-in syntax/modread with-module-reading-parameterization)) +(require racket/list + racket/pretty + racket/set + rackunit + syntax/parse + (only-in racket/format ~a) + (only-in syntax/modread with-module-reading-parameterization) + "../test-utils.rkt") (provide tests) (gen-test-main) @@ -29,10 +28,8 @@ (with-module-reading-parameterization (lambda () (read-syntax (object-name in-port) in-port)))))) - (define stx - (parameterize ((current-namespace (make-base-namespace))) - (expand mod-stx))) - stx) + (parameterize ([current-namespace (make-base-namespace)]) + (expand mod-stx))) ;; --- @@ -49,20 +46,25 @@ (define (stx-find orig-stx p?) (define stx* (stx-find* orig-stx p?)) - (if (or (null? stx*) - (not (null? (cdr stx*)))) - (raise-arguments-error 'stx-find "non-unique results" "num matches" (length stx*) "orig-stx" orig-stx "predicate" p? "matches" stx*) - (car stx*))) + (when (or (null? stx*) (not (null? (cdr stx*)))) + (raise-arguments-error 'stx-find + "non-unique results" + "num matches" + (length stx*) + "orig-stx" + orig-stx + "predicate" + p? + "matches" + stx*)) + (car stx*)) (define (stx-find* orig-stx p?) (let loop ((stx orig-stx)) (cond [(syntax? stx) - (let ((v (p? stx))) - (if v - (list - (if (eq? #true v) stx v)) - (loop (syntax-e stx))))] + (define v (p? stx)) + (if v (list (if (eq? #true v) stx v)) (loop (syntax-e stx)))] [(pair? stx) (append (loop (car stx)) (loop (cdr stx)))] [else @@ -79,37 +81,36 @@ ((~literal #%plain-app) (~datum shallow-shape-check) . _))) (define (stx-find-define-predicate-ctc stx pred-name) - (let* ((lift-id - (stx-find stx - (syntax-parser - #:datum-literals (define-values let-values #%app) - ((define-values (name:id) (let-values (((:id) (#%app fcp:id lift:id))) _)) - #:when (eq? (syntax-e #'name) pred-name) - #'lift) - (_ #f)) - )) - (lift-ctc - (stx-find stx - (syntax-parser - (((~datum define-values) (lt:id) ctc:id) - #:when (eq? (syntax-e #'lt) (syntax-e lift-id)) - #'ctc) - (_ #f)))) - (ctc* - (stx-find* stx - (syntax-parser - #:datum-literals (define-values lambda) - ((define-values (g:id) (lambda (_) body)) - #:when (eq? (syntax-e #'g) (syntax-e lift-ctc)) - #'body) - (_ #f))))) - (cond - [(null? ctc*) - lift-ctc] - [(null? (cdr ctc*)) - (car ctc*)] - [else - (raise-arguments-error 'stx-find-define-predicate-ctc "cannot find lifted" "pred" pred-name)]))) + (define lift-id + (stx-find stx + (syntax-parser + #:datum-literals (define-values let-values #%app) + [(define-values (name:id) + (let-values ([(:id) (#%app fcp:id lift:id)]) + _)) + #:when (eq? (syntax-e #'name) pred-name) + #'lift] + [_ #f]))) + (define lift-ctc + (stx-find stx + (syntax-parser + [((~datum define-values) (lt:id) ctc:id) + #:when (eq? (syntax-e #'lt) (syntax-e lift-id)) + #'ctc] + [_ #f]))) + (define ctc* + (stx-find* stx + (syntax-parser + #:datum-literals (define-values lambda) + [(define-values (g:id) (lambda (_) body)) + #:when (eq? (syntax-e #'g) (syntax-e lift-ctc)) + #'body] + [_ #f]))) + (cond + [(null? ctc*) lift-ctc] + [(null? (cdr ctc*)) (car ctc*)] + [else + (raise-arguments-error 'stx-find-define-predicate-ctc "cannot find lifted" "pred" pred-name)])) (define (split-shape-check stx) (define expr (->datum stx))