Skip to content
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
4 changes: 1 addition & 3 deletions typed-racket-lib/typed-racket/core.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
(with-refinements?))
(unless (eq? te-mode deep)
(raise-arguments-error
(string->symbol (format "typed/racket/~a"
(keyword->string
(syntax-e te-attr))))
(format-symbol "typed/racket/~a" te-attr)
"#:with-refinements unsupported")))])
(tc-module/full te-mode stx pmb-form
(λ (new-mod pre-before-code pre-after-code)
Expand Down
8 changes: 5 additions & 3 deletions typed-racket-lib/typed-racket/env/init-envs.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,11 @@

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

(define (make-init-code map f)
(define (bound-f id v)
Expand Down
7 changes: 3 additions & 4 deletions typed-racket-lib/typed-racket/logic/ineq.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,9 @@
;; --> (ax - bx) <= ...3 + ...4 - ...1 - ...2
[else
(define lhs* (lexp 0 (make-terms x (- x-lhs-coeff x-rhs-coeff))))
(define rhs*
(let ([rhs-c* (- rhs-c lhs-c)]
[rhs-h* (terms-subtract rhs-ts lhs-ts)])
(lexp rhs-c* (terms-remove rhs-h* x))))
(define rhs-c* (- rhs-c lhs-c))
(define rhs-h* (terms-subtract rhs-ts lhs-ts))
(define rhs* (lexp rhs-c* (terms-remove rhs-h* x)))
(leq lhs* rhs*)])]))

; x lhs
Expand Down
28 changes: 13 additions & 15 deletions typed-racket-lib/typed-racket/typecheck/possible-domains.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,18 @@
(match t
;; function type, prune if possible.
[(Fun: (list (Arrow: doms rests _ rngs rngs-T+) ...))
(match-let ([(list pdoms rngs rests)
(possible-domains doms rests rngs
(and expected (ret expected))
permissive?)])
(if (= (length pdoms) (length doms))
;; pruning didn't improve things, return the original
;; (Note: pruning may have reordered clauses, so may not be `equal?' to
;; the original, which may confuse `:print-type''s pruning detection)
t
;; pruning helped, return pruned type
(make-Fun (for/list ([pdom (in-list pdoms)]
[rst (in-list rests)]
[rng (in-list rngs)]
[T+ (in-list rngs-T+)])
(make-Arrow pdom rst null rng T+)))))]
(match-define (list pdoms rngs rests)
(possible-domains doms rests rngs (and expected (ret expected)) permissive?))
(if (= (length pdoms) (length doms))
;; pruning didn't improve things, return the original
;; (Note: pruning may have reordered clauses, so may not be `equal?' to
;; the original, which may confuse `:print-type''s pruning detection)
t
;; pruning helped, return pruned type
(make-Fun (for/list ([pdom (in-list pdoms)]
[rst (in-list rests)]
[rng (in-list rngs)]
[T+ (in-list rngs-T+)])
(make-Arrow pdom rst null rng T+))))]
;; not a function type. keep as is.
[_ t]))
65 changes: 32 additions & 33 deletions typed-racket-lib/typed-racket/typed-reader.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,39 @@
(define (parse port read-one src)
(skip-whitespace port)
(define name (read-one))
(begin0 (begin
(skip-whitespace port)
(let ([next (read-one)])
(case (syntax-e next)
;; type annotation
[(:)
(skip-whitespace port)
(type-label-property name (syntax->datum (read-one)))]
[(::)
(skip-whitespace port)
(datum->syntax name `(ann ,name : ,(read-one)))]
[(@)
(let ([elems (let loop ([es '()])
(skip-whitespace port)
(if (equal? #\} (peek-char port))
(reverse es)
(loop (cons (read-one) es))))])
(datum->syntax name `(inst ,name : ,@elems)))]
;; arbitrary property annotation
[(PROP)
(skip-whitespace port)
(begin0 (let ([next (read-one)])
(case (syntax-e next)
;; type annotation
[(:)
(skip-whitespace port)
(type-label-property name (syntax->datum (read-one)))]
[(::)
(skip-whitespace port)
(datum->syntax name `(ann ,name : ,(read-one)))]
[(@)
(let ([elems (let loop ([es '()])
(skip-whitespace port)
(if (equal? #\} (peek-char port))
(reverse es)
(loop (cons (read-one) es))))])
(datum->syntax name `(inst ,name : ,@elems)))]
;; arbitrary property annotation
[(PROP)
(skip-whitespace port)
(let* ([prop-name (syntax-e (read-one))])
(skip-whitespace port)
(let* ([prop-name (syntax-e (read-one))])
(skip-whitespace port)
(syntax-property name prop-name (read-one)))]
;; otherwise error
[else
(let-values ([(l c p) (port-next-location port)])
(raise-read-error (format "typed expression ~a must be followed by :, ::, or @"
(syntax->datum name))
src
l
c
p
1))])))
(syntax-property name prop-name (read-one)))]
;; otherwise error
[else
(let-values ([(l c p) (port-next-location port)])
(raise-read-error (format "typed expression ~a must be followed by :, ::, or @"
(syntax->datum name))
src
l
c
p
1))]))
(skip-whitespace port)
(let ([c (read-char port)])
(unless (equal? #\} c)
Expand Down
3 changes: 2 additions & 1 deletion typed-racket-test/succeed/shallow/pr241-variation-5.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@
(filtered-in
(if WARN-MISSING
(lambda (str)
(when (not (known-string? str)) (printf "WARNING: Missing test for base type '~a'\n" str))
(unless (known-string? str)
(printf "WARNING: Missing test for base type '~a'\n" str))
#f)
(lambda (str) #f))
typed-racket/base-env/base-types))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(module ty-foo typed/racket/shallow
(require/typed (submod ".." foo) [prop:hi (Struct-Property (-> Self Any))] [hi-ref (-> Any (-> Any Void))])
(struct bar () #:property prop:hi (λ ([self : bar])
(display (format "instance bar\n" ))))
(display "instance bar\n")))
(hi-ref (bar))
)

Expand Down
26 changes: 13 additions & 13 deletions typed-racket-test/unit-tests/type-alias-helper.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@

;; two aliases in their own components
(define example-1
(list (cons #'x (list #'x))
(cons #'y (list #'y))))
(list (list #'x #'x)
(list #'y #'y)))
;; all one component
(define example-2
(list (cons #'x (list #'x #'y))
(cons #'y (list #'x))))
(list (list #'x #'x #'y)
(list #'y #'x)))
;; two components, one with two nodes
(define example-3
(list (cons #'x (list #'y))
(cons #'y (list #'x))
(cons #'z (list))))
(list (list #'x #'y)
(list #'y #'x)
(list #'z)))
;; one with cycles, two that form a line
(define example-4
(list (cons #'x (list #'y))
(cons #'y (list #'x))
(cons #'a (list #'b))
(cons #'b (list))))
(list (list #'x #'y)
(list #'y #'x)
(list #'a #'b)
(list #'b)))
;; two large cycles
(define example-5
(list (cons #'x (list #'y #'z))
(cons #'y (list #'x))
(list (list #'x #'y #'z)
(list #'y #'x)
(cons #'z (list #'x #'y))
(cons #'a (list #'b))
(cons #'b (list #'c))
Expand Down
Loading