Skip to content

Automated Resyntax fixes #1458

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 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 3 deletions typed-racket-lib/typed-racket/core.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
(and (attribute opt?) (syntax-e (attribute opt?))))]
[with-refinements? (and (or (attribute refinement-reasoning?)
(with-refinements?))
(when (not (eq? te-mode deep))
(unless (eq? te-mode deep)
(raise-arguments-error
(string->symbol (format "typed/racket/~a" (keyword->string (syntax-e te-attr))))
"#:with-refinements unsupported")))])
(string->symbol (format "typed/racket/~a"
(keyword->string
(syntax-e te-attr))))
"#:with-refinements unsupported")))])
(tc-module/full te-mode stx pmb-form
(λ (new-mod pre-before-code pre-after-code)
(define ctc-cache (make-hash))
Expand Down
4 changes: 1 addition & 3 deletions typed-racket-lib/typed-racket/env/global-env.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@

(define (maybe-finish-register-type id)
(define v (free-id-table-ref the-mapping id))
(if (box? v)
(register-type id (unbox v))
#f))
(and (box? v) (register-type id (unbox v))))

(define (unregister-type id)
(free-id-table-remove! the-mapping id))
Expand Down
7 changes: 3 additions & 4 deletions typed-racket-lib/typed-racket/env/init-envs.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,9 @@

(define (bound-in-this-module id)
(define binding (identifier-binding id))
(if (and (list? binding) (module-path-index? (car binding)))
(let-values ([(mp base) (module-path-index-split (car binding))])
(not mp))
#f))
(and (and (list? binding) (module-path-index? (car binding)))
(let-values ([(mp base) (module-path-index-split (car binding))])
(not mp))))

(define (make-init-code map f)
(define (bound-f id v)
Expand Down
3 changes: 2 additions & 1 deletion typed-racket-lib/typed-racket/infer/infer-unit.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,8 @@
[(? variance:const?) S]
[(? variance:co?) S]
[(? variance:contra?) T]
[(? variance:inv?) (let ([gS (generalize S)]) (if (subtype gS T) gS S))]))
[(? variance:inv?) (define gS (generalize S))
(if (subtype gS T) gS S)]))

;; Since we don't add entries to the empty cset for index variables (since there is no
;; widest constraint, due to dcon-exacts), we must add substitutions here if no constraint
Expand Down
61 changes: 31 additions & 30 deletions typed-racket-lib/typed-racket/infer/intersect.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -178,37 +178,38 @@
(-unsafe-intersect initial-t1 initial-t2)
initial-t1)]
[else
(let ([t2 (if (resolvable? initial-t2)
(resolve-once initial-t2)
initial-t2)])
(cond
;; if t2 is not a fully defined type, do the simple thing
[(not t2)
(if additive?
(-unsafe-intersect t1 initial-t2)
t1)]
[else
;; we've never seen these types together before! let's gensym a symbol
;; so that if we do encounter them again, we can create a μ type.
(define name (gensym 'rec))
;; the 'record' contains the back pointer symbol we may or may not use in
;; the car, and a flag for whether or not we actually used the back pointer
;; in the cdr.
(define record (mcons name #f))
(define seen*
(list* (cons (cons initial-t1 initial-t2) record)
(cons (cons initial-t2 initial-t1) record)
seen))
(define t
(cond
[additive? (internal-intersect t1 t2 seen* obj)]
[else (internal-restrict t1 t2 seen* obj)]))
(define t2
(if (resolvable? initial-t2)
(resolve-once initial-t2)
initial-t2))
(cond
;; if t2 is not a fully defined type, do the simple thing
[(not t2)
(if additive?
(-unsafe-intersect t1 initial-t2)
t1)]
[else
;; we've never seen these types together before! let's gensym a symbol
;; so that if we do encounter them again, we can create a μ type.
(define name (gensym 'rec))
;; the 'record' contains the back pointer symbol we may or may not use in
;; the car, and a flag for whether or not we actually used the back pointer
;; in the cdr.
(define record (mcons name #f))
(define seen*
(list* (cons (cons initial-t1 initial-t2) record)
(cons (cons initial-t2 initial-t1) record)
seen))
(define t
(cond
;; check if we used the backpointer, if so,
;; make a recursive type using that name
[(mcdr record) (make-Mu name t)]
;; otherwise just return the result
[else t])]))]))
[additive? (internal-intersect t1 t2 seen* obj)]
[else (internal-restrict t1 t2 seen* obj)]))
(cond
;; check if we used the backpointer, if so,
;; make a recursive type using that name
[(mcdr record) (make-Mu name t)]
;; otherwise just return the result
[else t])])]))


;; intersect
Expand Down
4 changes: 2 additions & 2 deletions typed-racket-lib/typed-racket/private/type-contract.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@
[sc* (remove-duplicates sc*)]
[sc* (remove-overlap sc*
(list
(cons vector?/sc (list mutable-vector?/sc immutable-vector?/sc))
(cons hash?/sc (list mutable-hash?/sc weak-hash?/sc immutable-hash?/sc))))])
(list vector?/sc mutable-vector?/sc immutable-vector?/sc)
(list hash?/sc mutable-hash?/sc weak-hash?/sc immutable-hash?/sc)))])
(apply shallow-or/sc sc*))]
[t (t->sc t bound-all-vars)])]
[(Intersection: ts raw-prop)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@
(list invoke/scs ...)))
v)
(define (sig-spec->syntax sig-spec)
(match sig-spec
[(signature-spec name members scs)
(define member-stx (map (lambda (id sc) #`(#,id #,(f sc))) members scs))
#`(#,name #,@member-stx)]))
(match-define (signature-spec name members scs) sig-spec)
(define member-stx (map (lambda (id sc) #`(#,id #,(f sc))) members scs))
#`(#,name #,@member-stx))

(define (invokes->contract lst)
(cond
Expand Down
18 changes: 9 additions & 9 deletions typed-racket-lib/typed-racket/tc-setup.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
;; types are enforced (not no-check etc.),
;; PLT_TR_NO_OPTIMIZE is not set, and the
;; current code inspector has sufficient privileges
(if (and (optimize?)
(memq (current-type-enforcement-mode) (list deep shallow))
(not (getenv "PLT_TR_NO_OPTIMIZE"))
(authorized-code-inspector?))
(begin
(do-time "Starting optimizer")
(begin0 (stx-map optimize-top body)
(do-time "Optimized")))
body))
(cond
[(and (optimize?)
(memq (current-type-enforcement-mode) (list deep shallow))
(not (getenv "PLT_TR_NO_OPTIMIZE"))
(authorized-code-inspector?))
(do-time "Starting optimizer")
(begin0 (stx-map optimize-top body)
(do-time "Optimized"))]
[else body]))

(define (maybe-shallow-rewrite body-stx ctc-cache)
(case (current-type-enforcement-mode)
Expand Down
34 changes: 11 additions & 23 deletions typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -689,29 +689,17 @@
name-key-or-list))
(hash-ref parse-info name-key-or-list)))
(for/list ([m names]) (dict-ref local-table m)))
(define-values (localized-method-names
localized-field-pairs
localized-private-field-pairs
localized-inherit-field-pairs
localized-inherit-names
localized-private-methods
localized-override-names
localized-pubment-names
localized-augment-names
localized-inner-names
localized-init-names)
(values
(localize local-method-table 'method-internals)
(localize local-field-table 'field-internals)
(localize local-private-field-table 'private-fields)
(localize local-inherit-field-table 'inherit-field-internals)
(localize local-inherit-table 'inherit-internals)
(localize local-private-table 'private-names)
(localize local-super-table 'override-internals)
(localize local-augment-table 'pubment-internals)
(localize local-augment-table 'augment-internals)
(localize local-inner-table '(pubment-internals augment-internals))
(localize local-init-table 'only-init-internals)))
(define localized-method-names (localize local-method-table 'method-internals))
(define localized-field-pairs (localize local-field-table 'field-internals))
(define localized-private-field-pairs (localize local-private-field-table 'private-fields))
(define localized-inherit-field-pairs (localize local-inherit-field-table 'inherit-field-internals))
(define localized-inherit-names (localize local-inherit-table 'inherit-internals))
(define localized-private-methods (localize local-private-table 'private-names))
(define localized-override-names (localize local-super-table 'override-internals))
(define localized-pubment-names (localize local-augment-table 'pubment-internals))
(define localized-augment-names (localize local-augment-table 'augment-internals))
(define localized-inner-names (localize local-inner-table '(pubment-internals augment-internals)))
(define localized-init-names (localize local-init-table 'only-init-internals))
(define localized-field-get-names (map car localized-field-pairs))
(define localized-field-set-names (map cadr localized-field-pairs))
(define localized-private-field-get-names (map car localized-private-field-pairs))
Expand Down
3 changes: 2 additions & 1 deletion typed-racket-lib/typed-racket/typecheck/check-unit-unit.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@
;; this map is used to determine the actual signatures corresponding to the
;; given signature tags of the init-depends
(define tag-map (make-immutable-free-id-table (map cons import-tags import-sigs)))
(define lookup-temp (λ (temp) (free-id-table-ref export-temp-internal-map temp #f)))
(define (lookup-temp temp)
(free-id-table-ref export-temp-internal-map temp #f))

(values (for/list ([sig-id (in-list import-sigs)]
[sig-internal-ids (in-list import-internal-ids)])
Expand Down
Loading
Loading