Skip to content

Automated Resyntax fixes #1431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cdfcedf
Fix 1 occurrence of `define-lambda-to-define`
resyntax-ci[bot] Jan 24, 2025
1f68ac8
Fix 9 occurrences of `let-to-define`
resyntax-ci[bot] Jan 24, 2025
33d2b0d
Fix 6 occurrences of `define-syntax-syntax-rules-to-define-syntax-rule`
resyntax-ci[bot] Jan 24, 2025
5813d41
Fix 4 occurrences of `if-else-false-to-and`
resyntax-ci[bot] Jan 24, 2025
7ed7b36
Fix 1 occurrence of `inverted-when`
resyntax-ci[bot] Jan 24, 2025
0f2a1b2
Fix 2 occurrences of `zero-comparison-to-positive?`
resyntax-ci[bot] Jan 24, 2025
99a9fca
Fix 1 occurrence of `define-simple-macro-to-define-syntax-parse-rule`
resyntax-ci[bot] Jan 24, 2025
653a89e
Fix 1 occurrence of `provide-deduplication`
resyntax-ci[bot] Jan 24, 2025
e9f2368
Fix 1 occurrence of `if-let-to-cond`
resyntax-ci[bot] Jan 24, 2025
a74623c
Fix 1 occurrence of `apply-flattening`
resyntax-ci[bot] Jan 24, 2025
6569398
Fix 8 occurrences of `single-clause-match-to-match-define`
resyntax-ci[bot] Jan 24, 2025
d5996f9
Fix 2 occurrences of `define-values-values-to-define`
resyntax-ci[bot] Jan 24, 2025
ced28a9
Fix 4 occurrences of `quasiquote-to-list`
resyntax-ci[bot] Jan 24, 2025
56c5100
Fix 3 occurrences of `sort-with-keyed-comparator-to-sort-by-key`
resyntax-ci[bot] Jan 24, 2025
323d2ba
Fix 1 occurrence of `always-throwing-if-to-when`
resyntax-ci[bot] Jan 24, 2025
1688a4c
Fix 1 occurrence of `cond-let-to-cond-define`
resyntax-ci[bot] Jan 24, 2025
022742c
Fix 1 occurrence of `map-to-for`
resyntax-ci[bot] Jan 24, 2025
4c4c7ec
Fix 1 occurrence of `for/fold-result-keyword`
resyntax-ci[bot] Jan 24, 2025
924ff4a
Fix 1 occurrence of `apply-append-for-loop-to-for-loop`
resyntax-ci[bot] Jan 24, 2025
2fc4c48
Fix 1 occurrence of `when-expression-in-for-loop-to-when-keyword`
resyntax-ci[bot] Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions typed-racket-lib/typed-racket/base-env/annotate-classes.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
#:with ty #'t))
(define-splicing-syntax-class optional-standalone-annotation
(pattern (~optional a:standalone-annotation)
#:attr ty (if (attribute a) #'a.ty #f)))
#:attr ty (and (attribute a) #'a.ty)))

(define-syntax-class type-variables
#:attributes ((vars 1))
Expand Down Expand Up @@ -330,10 +330,8 @@
(define-values (all-mand-tys all-opt-tys)
(cond
[kw-property
(define-values (mand-kw-set opt-kw-set)
(values
(list->set (lambda-kws-mand kw-property))
(list->set (lambda-kws-opt kw-property))))
(define mand-kw-set (list->set (lambda-kws-mand kw-property)))
(define opt-kw-set (list->set (lambda-kws-opt kw-property)))

(define-values (mand-tys^ opt-kw^)
(partition (part-pred opt-kw-set)
Expand Down
6 changes: 5 additions & 1 deletion typed-racket-lib/typed-racket/base-env/base-structs.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@

(require (for-template racket/base (prefix-in k: '#%kernel)))

(provide initialize-structs -Date -Srcloc -Date -Arity-At-Least -Exn)
(provide initialize-structs
-Date
-Srcloc
-Arity-At-Least
-Exn)

(define-syntax define-hierarchy
(syntax-rules (define-hierarchy)
Expand Down
8 changes: 2 additions & 6 deletions typed-racket-lib/typed-racket/base-env/unit-prims.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,8 @@
;; in the signature, this is needed to typecheck define-values/invoke-unit forms
(define-for-syntax (imports/members sig-id)
(define-values (_1 imp-mem _2 _3) (signature-members sig-id sig-id))
#`(#,sig-id #,@(map (lambda (id)
(local-expand
id
(syntax-local-context)
(kernel-form-identifier-list)))
imp-mem)))
#`(#,sig-id #,@(for/list ([id (in-list imp-mem)])
(local-expand id (syntax-local-context) (kernel-form-identifier-list)))))

;; Given a list of signature specs
;; Processes each signature spec to determine the variables exported
Expand Down
47 changes: 16 additions & 31 deletions typed-racket-lib/typed-racket/types/base-abbrev.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,11 @@
(foldr -pair b l))

;; Recursive types
(define-syntax -v
(syntax-rules ()
[(_ x) (make-F 'x)]))
(define-syntax-rule (-v x)
(make-F 'x))

(define-syntax -mu
(syntax-rules ()
[(_ var ty)
(let ([var (-v var)])
(make-Mu 'var ty))]))
(define-syntax-rule (-mu var ty)
(let ([var (-v var)]) (make-Mu 'var ty)))

;; Results
(define/cond-contract (-result t [pset -tt-propset] [o -empty-obj])
Expand Down Expand Up @@ -493,31 +489,20 @@


;; Convenient syntax for polymorphic types
(define-syntax -poly
(syntax-rules ()
[(_ (vars ...) ty)
(let ([vars (-v vars)] ...)
(make-Poly (list 'vars ...) ty))]))

(define-syntax -polydots
(syntax-rules ()
[(_ (vars ... dotted) ty)
(let ([dotted (-v dotted)]
[vars (-v vars)] ...)
(make-PolyDots (list 'vars ... 'dotted) ty))]))

(define-syntax -polyrow
(syntax-rules ()
[(_ (var) consts ty)
(let ([var (-v var)])
(make-PolyRow (list 'var) ty consts))]))
(define-syntax-rule (-poly (vars ...) ty)
(let ([vars (-v vars)] ...) (make-Poly (list 'vars ...) ty)))

(define-syntax-rule (-polydots (vars ... dotted) ty)
(let ([dotted (-v dotted)]
[vars (-v vars)] ...)
(make-PolyDots (list 'vars ... 'dotted) ty)))

(define-syntax-rule (-polyrow (var) consts ty)
(let ([var (-v var)]) (make-PolyRow (list 'var) ty consts)))

;; abbreviation for existential types
(define-syntax -some
(syntax-rules ()
[(_ (vars ...) ty)
(let ([vars (-v vars)] ...)
(make-Some (list 'vars ...) ty))]))
(define-syntax-rule (-some (vars ...) ty)
(let ([vars (-v vars)] ...) (make-Some (list 'vars ...) ty)))

;; abbreviation for existential type results
(define-syntax -some-res
Expand Down
6 changes: 3 additions & 3 deletions typed-racket-lib/typed-racket/types/classes.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@
(match-define (Row: inits fields methods augments _) row)
;; check a given clause type (e.g., init, field)
(define (check-clauses row-dict absence-set)
(for ([(name _) (in-dict row-dict)])
(when (member name absence-set)
(fail name))))
(for ([(name _) (in-dict row-dict)]
#:when (member name absence-set))
(fail name)))
(check-clauses inits init-absents)
(check-clauses fields field-absents)
(check-clauses methods method-absents)
Expand Down
18 changes: 9 additions & 9 deletions typed-racket-lib/typed-racket/types/generalize.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
[(Pair: t1 (== -Null)) (-lst t1)]
[(MPair: t1 (== -Null)) (-mlst t1)]
[(or (Pair: t1 t2) (MPair: t1 t2))
(let ([t-new (loop t2)])
(define -lst-type
((match t*
[(Pair: _ _) -lst]
[(MPair: _ _) -mlst])
t1))
(if (type-equiv? -lst-type t-new)
-lst-type
(exit t)))]
(define t-new (loop t2))
(define -lst-type
((match t*
[(Pair: _ _) -lst]
[(MPair: _ _) -mlst])
t1))
(if (type-equiv? -lst-type t-new)
-lst-type
(exit t))]
[(ListDots: t bound) (-lst (substitute Univ bound t))]
[(? (lambda (t) (subtype t -Symbol))) -Symbol]
[(== -True) -Boolean]
Expand Down
71 changes: 35 additions & 36 deletions typed-racket-lib/typed-racket/types/kw-types.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
;; the kw protocol puts the arguments in keyword-sorted order in the
;; function header, so we need to sort the types to match
(define sorted-kws
(sort keywords (λ (kw1 kw2) (keyword<? (Keyword-kw kw1)
(Keyword-kw kw2)))))
(sort keywords keyword<? #:key Keyword-kw))

(define pos-opt-arg-types
(append (for/list ([t (in-list optional-arg-types)]
Expand Down Expand Up @@ -148,9 +147,7 @@
(define (calculate-mandatory-args orig-arrows)
;; sorted order is important, our loops below rely on this order
(define arity-sorted-arrows
(sort orig-arrows
(λ (a1 a2) (>= (Arrow-max-arity a1)
(Arrow-max-arity a2)))))
(sort orig-arrows >= #:key Arrow-max-arity))
(for/fold ([mand-arg-table '()])
([arrow (in-list arity-sorted-arrows)])
(cond
Expand All @@ -172,36 +169,38 @@
;; set and set->list to retain determinism
(remove-duplicates
(for/list ([(arrow arrow-mand-arg-count) (in-assoc mand-arg-table)])
(match arrow
[(Arrow: dom rst kws rng rng-T+)
(define kws* (if actual-kws
(handle-extra-or-missing-kws kws actual-kws)
kws))
(define kw-opts-supplied (if actual-kws
(lambda-kws-opt-supplied actual-kws)
'()))
(define mand-arg-count (if actual-kws
(lambda-kws-pos-mand-count actual-kws)
arrow-mand-arg-count))
(define opt-arg-count (- (length dom) mand-arg-count))
(define extra-opt-arg-count
;; In case `dom` has too many arguments that we try to treat
;; as optional:
(if actual-kws
(max 0 (- opt-arg-count (length (lambda-kws-pos-opt-supplied? actual-kws))))
0))
(convert kws*
kw-opts-supplied
(take dom mand-arg-count)
(drop dom mand-arg-count)
(if actual-kws
(append (lambda-kws-pos-opt-supplied? actual-kws)
(make-list extra-opt-arg-count #f))
(make-list opt-arg-count #f))
rng
rst
split?
rng-T+)]))))
(match-define (Arrow: dom rst kws rng rng-T+) arrow)
(define kws*
(if actual-kws
(handle-extra-or-missing-kws kws actual-kws)
kws))
(define kw-opts-supplied
(if actual-kws
(lambda-kws-opt-supplied actual-kws)
'()))
(define mand-arg-count
(if actual-kws
(lambda-kws-pos-mand-count actual-kws)
arrow-mand-arg-count))
(define opt-arg-count (- (length dom) mand-arg-count))
(define extra-opt-arg-count
;; In case `dom` has too many arguments that we try to treat
;; as optional:
(if actual-kws
(max 0 (- opt-arg-count (length (lambda-kws-pos-opt-supplied? actual-kws))))
0))
(convert kws*
kw-opts-supplied
(take dom mand-arg-count)
(drop dom mand-arg-count)
(if actual-kws
(append (lambda-kws-pos-opt-supplied? actual-kws)
(make-list extra-opt-arg-count #f))
(make-list opt-arg-count #f))
rng
rst
split?
rng-T+))))
(apply cl->* fns))

;; kw-convert : Type (Option LambdaKeywords) [Boolean] -> Type
Expand Down Expand Up @@ -269,7 +268,7 @@
(take opt-types to-take))
(erase-props/Values rng)
#:kws actual-kws
#:rest (if (= to-take opt-types-count) rest-type #f)
#:rest (and (= to-take opt-types-count) rest-type)
#:T+ rng-T+)))]
[else (int-err "unsupported arrs in keyword function type")])]
[(Poly-names: names f) (make-Poly names (loop f))]
Expand Down
2 changes: 1 addition & 1 deletion typed-racket-lib/typed-racket/types/match-expanders.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
(app (λ (t) (Listof? t #t)) (? Type? elem-pat)))])))


(define-simple-macro (make-Listof-pred listof-pred?:id pair-matcher:id)
(define-syntax-parse-rule (make-Listof-pred listof-pred?:id pair-matcher:id)
(define (listof-pred? t [simple? #f])
(match t
[(Mu-unsafe:
Expand Down
Loading
Loading