Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Cleaned up version of annotation code #414

Closed
wants to merge 21 commits into from

3 participants

@endobson

Needs the new version of TR unit testing code to correctly work, but the changes are separate.

@endobson

Ping.

@endobson

Ping.

@samth samth commented on the diff
...d-racket-lib/typed-racket/private/type-annotation.rkt
((12 lines not shown))
(cond
[(type-ascription-property stx)
=>
(lambda (prop)
- (let loop ((prop prop))
@samth Collaborator
samth added a note

Why is taking out this loop ok? Are we guaranteed never to merge these properties?

Yes, because merging the properties happened because two annotations could apply properties to the same syntax object. Now since they are on the #%expression that cannot happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...d-racket-lib/typed-racket/typecheck/tc-expression.rkt
((26 lines not shown))
+ (define-syntax-class name
+ #:literal-sets (kernel-literals)
+ (pattern (~and exp #%expression)
+ (?@ #:attr attr (acc #'exp)) ...
+ (?@ #:when (attribute attr)) ...)) ...)))))
+
+(define-expression-annotations
+ (type-inst (vars type-inst-property))
+ (external-check (check external-check-property))
+ (type-ascrip
+ (ty type-ascription)
+ (scoped-vars ascribed-scoped-type-vars)))
+
+
+;; Typecheck an (#%expression e) form
+(define (tc/expression form expected)
@samth Collaborator
samth added a note

I think tc/expression is a confusing name here -- I know we can't use tc/#%expression, but something to indicate the real purpose would be good.

Isn't that a valid identifier?

Welcome to Racket v6.0.0.1.
-> (define tc/#%expression 3)
-> tc/#%expression
3
@samth Collaborator
samth added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...d-racket-lib/typed-racket/typecheck/tc-expression.rkt
((44 lines not shown))
+ (do-inst (tc-expr #'e) (attribute exp.vars))]
+ [(exp:type-ascrip e)
+ (add-scoped-tvars #'e (attribute exp.scoped-vars))
+ (tc-expr/check #'e (attribute exp.ty))]
+ [(exp:external-check e)
+ ((attribute exp.check) #'e)
+ (if expected
+ (tc-expr/check #'e expected)
+ (tc-expr #'e))]
+ [(_ e)
+ (if expected
+ (tc-expr/check #'e expected)
+ (tc-expr #'e))]))
+
+
+;; do-inst : syntax? tc-results/c -> tc-results/c
@samth Collaborator
samth added a note

This should be (or/c #f syntax?), right?

I assume you meant (or/c tc-results/c #f), which is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...d-racket-lib/typed-racket/typecheck/tc-expression.rkt
((60 lines not shown))
+(define (do-inst results inst)
+ (when (and inst (not (syntax? inst)))
+ (int-err "Bad type-inst property ~a" inst))
+ (match results
+ [(tc-result1: ty f o)
+ (define new-ty
+ (cond
+ [(not inst) ty]
+ [(not (or (Poly? ty) (PolyDots? ty)))
+ (tc-error/expr "Cannot instantiate non-polymorphic type ~a"
+ (cleanup-type ty))]
+ [(and (Poly? ty)
+ (not (= (syntax-length inst) (Poly-n ty))))
+ (tc-error/expr "Wrong number of type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
+ (cleanup-type ty) (Poly-n ty) (syntax-length inst))]
+ [(and (PolyDots? ty) (not (>= (syntax-length inst) (sub1 (PolyDots-n ty)))))
@samth Collaborator
samth added a note

We could use < here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...d-racket-lib/typed-racket/typecheck/tc-expression.rkt
((68 lines not shown))
+ [(not (or (Poly? ty) (PolyDots? ty)))
+ (tc-error/expr "Cannot instantiate non-polymorphic type ~a"
+ (cleanup-type ty))]
+ [(and (Poly? ty)
+ (not (= (syntax-length inst) (Poly-n ty))))
+ (tc-error/expr "Wrong number of type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
+ (cleanup-type ty) (Poly-n ty) (syntax-length inst))]
+ [(and (PolyDots? ty) (not (>= (syntax-length inst) (sub1 (PolyDots-n ty)))))
+ ;; we can provide 0 arguments for the ... var
+ (tc-error/expr "Wrong number of type arguments to polymorphic type ~a:\nexpected at least: ~a\ngot: ~a"
+ (cleanup-type ty) (sub1 (PolyDots-n ty)) (syntax-length inst))]
+ [(PolyDots? ty)
+ ;; In this case, we need to check the last thing. If it's a dotted var, then we need to
+ ;; use instantiate-poly-dotted, otherwise we do the normal thing.
+ ;; In the case that the list is empty we also do the normal thing
+ (let ((stx-list (syntax->list inst)))
@samth Collaborator
samth added a note

Nit: [].

@samth Collaborator
samth added a note

Or internal-define.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
...d-racket-lib/typed-racket/typecheck/tc-expression.rkt
((69 lines not shown))
+ (tc-error/expr "Cannot instantiate non-polymorphic type ~a"
+ (cleanup-type ty))]
+ [(and (Poly? ty)
+ (not (= (syntax-length inst) (Poly-n ty))))
+ (tc-error/expr "Wrong number of type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
+ (cleanup-type ty) (Poly-n ty) (syntax-length inst))]
+ [(and (PolyDots? ty) (not (>= (syntax-length inst) (sub1 (PolyDots-n ty)))))
+ ;; we can provide 0 arguments for the ... var
+ (tc-error/expr "Wrong number of type arguments to polymorphic type ~a:\nexpected at least: ~a\ngot: ~a"
+ (cleanup-type ty) (sub1 (PolyDots-n ty)) (syntax-length inst))]
+ [(PolyDots? ty)
+ ;; In this case, we need to check the last thing. If it's a dotted var, then we need to
+ ;; use instantiate-poly-dotted, otherwise we do the normal thing.
+ ;; In the case that the list is empty we also do the normal thing
+ (let ((stx-list (syntax->list inst)))
+ (if (null? stx-list)
@samth Collaborator
samth added a note

Merge this if into the match below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samth samth commented on the diff
...ests/typed-racket/unit-tests/type-annotation-test.rkt
@@ -1,40 +0,0 @@
-#lang scheme/base
@samth Collaborator
samth added a note

Why are we dropping these tests?

Because they were broken (in terms of phasing) and didn't offer any more coverage than our typecheck tests of similar programs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samth samth commented on the diff
.../tests/typed-racket/optimizer/tests/dead-inf-comp.rkt
@@ -18,9 +18,6 @@ TR info: dead-inf-comp.rkt 204:4 (>= -inf.f rat) -- exact real arith
TR info: dead-inf-comp.rkt 207:4 (>= rat -inf.f) -- exact real arith
TR info: dead-inf-comp.rkt 212:41 displayln -- hidden parameter
TR info: dead-inf-comp.rkt 212:41 displayln -- hidden parameter
-TR opt: dead-inf-comp.rkt 102:0 #%module-begin -- dead else branch
@samth Collaborator
samth added a note

Why does this change affect the optimizer output?

Not sure exactly, but it looks like it is better. The dead else branch was not at the module begin but inside the for loop. My guess is that the #%expression allowed it to find it correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samth samth commented on the diff
.../tests/typed-racket/optimizer/tests/vector-length.rkt
@@ -1,7 +1,7 @@
#;#;
#<<END
TR opt: vector-length.rkt 15:0 (vector-length (vector 1 2 3)) -- known-length vector-length
-TR opt: vector-length.rkt 16:0 (vector-length (ann (vector 4 5 6) (Vectorof Integer))) -- known-length vector-length
+TR opt: vector-length.rkt 16:0 (vector-length (ann (vector 4 5 6) (Vectorof Integer))) -- vector-length
@samth Collaborator
samth added a note

Why are there fewer optimizations here?

Because the optimizer can no longer see through type annotations. The type of the expression is (Vectorof Integer) not (Vector Integer Integer Integer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@endobson

I believe have addressed all the current comments.

@endobson

Is this good to go in with fixups merged?

@samth
Collaborator

Yes, r+ for this.

@samth
Collaborator

@shekari ping?

@endobson

As I merged this forward I ran into the match bug with multiple (list a ...) patterns. To solve that I needed to fix check-below. Fixing check below correctly required fixing a bunch of cases that were misusing expected values.

So long story short this is in the process of being merged but it is non trivial due to it bringing up other bugs.

@endobson

This is finally all in.

@endobson endobson closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 20, 2013
  1. @endobson
  2. @endobson
  3. @endobson
  4. @endobson
  5. @endobson
  6. @endobson
  7. @endobson
  8. @endobson

    Cleanup type-ascription.

    endobson authored
  9. @endobson
  10. @endobson
  11. @endobson
  12. @endobson
  13. @endobson

    Cleanup obsolete loop.

    endobson authored
  14. @endobson
  15. @endobson

    Cleanup tc-expression.

    endobson authored
  16. @endobson
  17. @endobson

    Fix scoped type variables.

    endobson authored
Commits on Jan 16, 2014
  1. @endobson
  2. @endobson
  3. @endobson
  4. @endobson
This page is out of date. Refresh to see the latest.
Showing with 291 additions and 352 deletions.
  1. +0 −7 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/annotate-classes.rkt
  2. +55 −44 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt
  3. +0 −3  pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/parse-type.rkt
  4. +15 −28 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-annotation.rkt
  5. +3 −0  pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/signatures.rkt
  6. +5 −3 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app/tc-app-lambda.rkt
  7. +0 −12 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app/tc-app-main.rkt
  8. +9 −112 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt
  9. +103 −0 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-expression.rkt
  10. +2 −2 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/typechecker.rkt
  11. +3 −3 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/dead-inf-comp.rkt
  12. +4 −4 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/pr13468.rkt
  13. +20 −20 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/unboxed-for.rkt
  14. +1 −1  pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/vector-length.rkt
  15. +71 −71 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/vector-sum.rkt
  16. +0 −2  pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/all-tests.rkt
  17. +0 −40 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/type-annotation-test.rkt
View
7 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/annotate-classes.rkt
@@ -138,10 +138,3 @@
#:with ann-formals #'(n.ann-name ... . rest.ann-name)
#:with (arg-ty ...) #'(n.ty ... . rest.formal-ty)))
-(define-splicing-syntax-class standalone-annotation
- #:literals (:)
- (pattern (~seq : t)
- #:with ty #'t))
-(define-splicing-syntax-class optional-standalone-annotation
- (pattern (~optional a:standalone-annotation)
- #:with ty (if (attribute a) #'a.ty #f)))
View
99 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt
@@ -255,7 +255,8 @@ This file defines two sorts of primitives. All of them are provided into any mod
type)))
#`(ann
- #,(external-check-property (ignore-some-property name #t) check-valid-type)
+ (#,(external-check-property #'#%expression check-valid-type)
+ #,(ignore-some-property name #t))
(Any -> Boolean : ty)))
(let ([typ (parse-type #'ty)])
(if (Error? typ)
@@ -304,7 +305,8 @@ This file defines two sorts of primitives. All of them are provided into any mod
(tc-error/delayed
"Type ~a could not be converted to a contract because it contains free variables."
type)))
- (external-check-property (apply-contract ctc) check-valid-type))]
+ #`(#,(external-check-property #'#%expression check-valid-type)
+ #,(apply-contract ctc)))]
[else
(let ([typ (parse-type #'ty)])
(if (Error? typ)
@@ -354,29 +356,23 @@ This file defines two sorts of primitives. All of them are provided into any mod
(define-syntax (plambda: stx)
(syntax-parse stx
[(plambda: tvars:type-variables formals . body)
- (quasisyntax/loc stx
- (#%expression
- #,(plambda-property
- (syntax/loc stx (lambda: formals . body))
- #'(tvars.vars ...))))]))
+ (plambda-property
+ (syntax/loc stx (lambda: formals . body))
+ #'(tvars.vars ...)) ]))
(define-syntax (pcase-lambda: stx)
(syntax-parse stx
[(pcase-lambda: tvars:type-variables cl ...)
- (quasisyntax/loc stx
- (#%expression
- #,(plambda-property
- (syntax/loc stx (case-lambda: cl ...))
- #'(tvars.vars ...))))]))
+ (plambda-property
+ (syntax/loc stx (case-lambda: cl ...))
+ #'(tvars.vars ...))]))
(define-syntax (popt-lambda: stx)
(syntax-parse stx
[(popt-lambda: tvars:type-variables formals . body)
- (quasisyntax/loc stx
- (#%expression
- #,(plambda-property
- (syntax/loc stx (opt-lambda: formals . body))
- #'(tvars.vars ...))))]))
+ (plambda-property
+ (syntax/loc stx (opt-lambda: formals . body))
+ #'(tvars.vars ...))]))
(define-syntax (pdefine: stx)
(syntax-parse stx #:literals (:)
@@ -390,7 +386,13 @@ This file defines two sorts of primitives. All of them are provided into any mod
(define-syntax (ann stx)
(syntax-parse stx #:literals (:)
[(_ (~or (~seq arg : ty) (~seq arg ty)))
- (type-ascription-property #'arg #'ty)]))
+ (add-ann #'arg #'ty)]))
+
+(define-for-syntax (add-ann expr-stx ty-stx)
+ (quasisyntax/loc expr-stx
+ (#,(type-ascription-property #'#%expression ty-stx)
+ #,expr-stx)))
+
(define-syntax (inst stx)
(syntax-parse stx #:literals (:)
@@ -398,9 +400,11 @@ This file defines two sorts of primitives. All of them are provided into any mod
(syntax/loc stx (inst arg . tys))]
[(_ arg tys ... ty ddd b:id)
#:when (eq? (syntax-e #'ddd) '...)
- (type-inst-property (syntax/loc #'arg (#%expression arg)) #'(tys ... (ty . b)))]
+ (with-syntax ([expr (type-inst-property #'#%expression #'(tys ... (ty . b)))])
+ (syntax/loc #'arg (expr arg)))]
[(_ arg tys ...)
- (type-inst-property (syntax/loc #'arg (#%expression arg)) #'(tys ...))]))
+ (with-syntax ([expr (type-inst-property #'#%expression #'(tys ...))])
+ (syntax/loc #'arg (expr arg)))]))
(define-syntax (define: stx)
(syntax-parse stx #:literals (:)
@@ -813,8 +817,8 @@ This file defines two sorts of primitives. All of them are provided into any mod
[(_ (~optional (~seq : Void))
;; c is not always an expression, could be a break-clause
clauses c ...) ; no need to annotate the type, it's always Void
- (let ((body #`(; break-clause ...
- #,@(type-ascription-property #'(c ...) #'Void))))
+ (let ((body #'(; break-clause ...
+ c ...)))
(let loop ((clauses #'clauses))
(define-splicing-syntax-class for-clause
;; single-valued seq-expr
@@ -837,14 +841,14 @@ This file defines two sorts of primitives. All of them are provided into any mod
#:with replace-with #'unless))
(syntax-parse clauses
[(head:for-clause next:for-clause ... kw:for-kw rest ...)
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for
(head.expand ... next.expand ... ...)
#,(loop #'(kw rest ...))))
#'Void)]
[(head:for-clause ...) ; we reached the end
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for
(head.expand ... ...)
@@ -859,10 +863,20 @@ This file defines two sorts of primitives. All of them are provided into any mod
(kw.replace-with guard
#,(loop #'(rest ...))))])))]))
-(define-for-syntax (maybe-annotate-body body ty)
- (if (syntax-e ty)
- (type-ascription-property body ty)
- body))
+(begin-for-syntax
+ (define-splicing-syntax-class standalone-annotation
+ #:attributes (ty)
+ #:literals (:)
+ (pattern (~seq : ty)))
+
+ (define-splicing-syntax-class optional-standalone-annotation
+ #:attributes (ty annotate)
+ (pattern (~optional :standalone-annotation)
+ #:attr annotate
+ (λ (stx)
+ (if (attribute ty)
+ (add-ann stx #'ty)
+ stx)))))
;; Handling #:when clauses manually, like we do with for: above breaks
;; the semantics of for/list and co.
@@ -876,14 +890,12 @@ This file defines two sorts of primitives. All of them are provided into any mod
[(_ a:optional-standalone-annotation
clause:for-clauses
c ...) ; c is not always an expression, can be a break-clause
- (maybe-annotate-body
+ ((attribute a.annotate)
(quasisyntax/loc stx
(#,name
(clause.expand ... ...)
- #,@(maybe-annotate-body
- #'(c ...)
- #'a.ty)))
- #'a.ty)])))
+ c ...)))])))
+
(define-syntax (define-for-variants stx)
(syntax-parse stx
[(_ (name untyped-name) ...)
@@ -908,7 +920,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
((var:optionally-annotated-name) ...)
clause:for-clauses
c ...) ; c is not always an expression, can be a break-clause
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for/lists (var.ann-name ...)
(clause.expand ... ...)
@@ -917,7 +929,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
[(_ ((var:annotated-name) ...)
clause:for-clauses
c ...)
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for/lists (var.ann-name ...)
(clause.expand ... ...)
@@ -929,7 +941,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
((var:optionally-annotated-name init:expr) ...)
clause:for-clauses
c ...) ; c is not always an expression, can be a break-clause
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for/fold ((var.ann-name init) ...)
(clause.expand ... ...)
@@ -938,7 +950,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
[(_ accum:accumulator-bindings
clause:for-clauses
c ...)
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for/fold ((accum.ann-name accum.init) ...)
(clause.expand ... ...)
@@ -962,11 +974,10 @@ This file defines two sorts of primitives. All of them are provided into any mod
[(_ a:optional-standalone-annotation
clause:for-clauses
c ...) ; c is not always an expression, can be a break-clause
- (maybe-annotate-body
+ ((attribute a.annotate)
(quasisyntax/loc stx
(#,name (clause.expand ... ...)
- c ...))
- #'a.ty)])))
+ c ...)))])))
(define-syntax (define-for*-variants stx)
(syntax-parse stx
[(_ (name no-colon-name) ...)
@@ -987,7 +998,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
((var:optionally-annotated-name) ...)
clause:for-clauses
c ...) ; c is not always an expression, can be a break-clause
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for/lists (var.ann-name ...)
(clause.expand* ... ...)
@@ -996,7 +1007,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
[(_ ((var:annotated-name) ...)
clause:for-clauses
c ...)
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for/lists (var.ann-name ...)
(clause.expand* ... ...)
@@ -1008,7 +1019,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
((var:optionally-annotated-name init:expr) ...)
clause:for-clauses
c ...) ; c is not always an expression, can be a break-clause
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for/fold ((var.ann-name init) ...)
(clause.expand* ... ...)
@@ -1017,7 +1028,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
[(_ ((var:annotated-name init:expr) ...)
clause:for-clauses
c ...)
- (type-ascription-property
+ (add-ann
(quasisyntax/loc stx
(for/fold ((var.ann-name init) ...)
(clause.expand* ... ...)
View
3  pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/parse-type.rkt
@@ -24,7 +24,6 @@
;; context of the given syntax object
[parse-type/id (syntax? c:any/c . c:-> . Type/c)]
[parse-tc-results (syntax? . c:-> . tc-results/c)]
- [parse-tc-results/id (syntax? c:any/c . c:-> . tc-results/c)]
[parse-literal-alls (syntax? . c:-> . (c:listof (c:or/c (c:listof identifier?) (c:list/c (c:listof identifier?) identifier?))))])
(provide star ddd/bound)
@@ -505,6 +504,4 @@
(stx-map (lambda (x) (make-NoObject)) #'(t ...)))]
[t (ret (parse-type #'t) (make-NoFilter) (make-NoObject))]))
-(define parse-tc-results/id (parse/id parse-tc-results))
-
(define parse-type/id (parse/id parse-type))
View
43 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-annotation.rkt
@@ -4,17 +4,17 @@
(rep type-rep)
(utils tc-utils)
(env global-env mvar-env scoped-tvar-env)
- (except-in (types subtype union utils generalize))
+ (types subtype union resolve utils generalize)
(private parse-type syntax-properties)
(contract-req)
racket/match)
(provide type-annotation
+ ascribed-scoped-type-vars
get-type
get-types
get-type/infer
type-ascription
- remove-ascription
check-type
dotted?)
@@ -38,7 +38,6 @@
;(printf "in type-annotation:~a\n" (syntax->datum stx))
(cond
[(type-label-property stx) => pt]
- [(type-ascription-property stx) => pt]
;; this is so that : annotation works in internal def ctxts
[(and (identifier? stx) (lookup-type stx (lambda () #f)))
=>
@@ -47,38 +46,26 @@
t)]
[else #f]))
-;(trace type-annotation)
-
(define (type-ascription stx)
- (define (pt prop)
- (add-scoped-tvars stx (parse-literal-alls prop))
- (if (syntax? prop)
- (parse-tc-results prop)
- (parse-tc-results/id stx prop)))
(cond
[(type-ascription-property stx)
=>
(lambda (prop)
- (let loop ((prop prop))
@samth Collaborator
samth added a note

Why is taking out this loop ok? Are we guaranteed never to merge these properties?

Yes, because merging the properties happened because two annotations could apply properties to the same syntax object. Now since they are on the #%expression that cannot happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- (if (pair? prop)
- (loop (cdr prop))
- (pt prop))))]
+ (unless (syntax? prop)
+ (int-err "Type ascription is bad: ~a" prop))
+ (parse-tc-results prop))]
+ [else #f]))
+
+(define (ascribed-scoped-type-vars stx)
+ (cond
+ [(type-ascription-property stx)
+ =>
+ (lambda (prop)
+ (unless (syntax? prop)
+ (int-err "Type ascription is bad: ~a" prop))
+ (parse-literal-alls prop))]
[else #f]))
-(define (remove-ascription stx)
- (type-ascription-property
- stx
- (cond
- [(type-ascription-property stx)
- =>
- (lambda (prop)
- (if (pair? prop)
- (let loop ((prop (cdr prop)) (last (car prop)))
- (if (pair? prop)
- (cons last (loop (cdr prop) (car prop)))
- last))
- #f))]
- [else #f])))
;; get the type annotation of this identifier, otherwise error
;; if #:default is provided, return that instead of error
View
3  pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/signatures.rkt
@@ -28,6 +28,9 @@
(define-signature tc-send^
([cond-contracted tc/send ((syntax? syntax? syntax? syntax?) ((or/c tc-results/c #f)) . ->* . tc-results/c)]))
+(define-signature tc-expression^
+ ([cond-contracted tc/#%expression (syntax? (or/c tc-results/c #f) . ->* . tc-results/c)]))
+
(define-signature tc-lambda^
([cond-contracted tc/lambda (syntax? syntax? syntax? . -> . tc-results/c)]
[cond-contracted tc/lambda/check (syntax? syntax? syntax? tc-results/c . -> . tc-results/c)]
View
8 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app/tc-app-lambda.rkt
@@ -7,7 +7,7 @@
unstable/sequence unstable/syntax
(typecheck signatures find-annotation)
(types abbrev utils generalize type-table)
- (private type-annotation)
+ (private type-annotation syntax-properties)
(for-template racket/base))
@@ -24,7 +24,8 @@
#:fail-unless (free-identifier=? #'lp #'lp*) #f
(let-loop-check #'lam #'lp #'actuals #'(args ...) #'body expected))
;; inference for ((lambda
- (pattern ((#%plain-lambda (x ...) . body) args ...)
+ (pattern ((~and lam (#%plain-lambda (x ...) . body)) args ...)
+ #:fail-when (plambda-property #'lam) #f
#:fail-unless (= (syntax-length #'(x ...))
(syntax-length #'(args ...))) #f
#:fail-when (andmap type-annotation (syntax->list #'(x ...))) #f
@@ -32,7 +33,8 @@
#'(let-values ([(x) args] ...) . body)
expected))
;; inference for ((lambda with dotted rest
- (pattern ((#%plain-lambda (x ... . rst:id) . body) args ...)
+ (pattern ((~and lam (#%plain-lambda (x ... . rst:id) . body)) args ...)
+ #:fail-when (plambda-property #'lam) #f
#:fail-unless (<= (syntax-length #'(x ...))
(syntax-length #'(args ...))) #f
;; FIXME - remove this restriction - doesn't work because the annotation
View
12 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-app/tc-app-main.rkt
@@ -15,17 +15,6 @@
tc-app-objects^ tc-app-eq^ tc-app-lambda^ tc-app-special^)
(export tc-app^)
-
-(define-syntax-class annotated-op
- (pattern i:identifier
- #:when (or (type-inst-property #'i)
- (type-ascription-property #'i))))
-
-(define-tc/app-syntax-class (tc/app-annotated expected)
- ;; Just do regular typechecking if we have one of these.
- (pattern (~and form (rator:annotated-op . rands))
- (tc/app-regular #'form expected)))
-
(define-tc/app-syntax-class (tc/app-regular* expected)
(pattern form (tc/app-regular #'form expected)))
@@ -36,7 +25,6 @@
#:attr check (attribute v.check)) ...))
(combine-tc/app-syntax-classes tc/app-special-cases
- tc/app-annotated
tc/app-list
tc/app-apply
tc/app-eq
View
121 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt
@@ -18,68 +18,9 @@
(require (for-template racket/base racket/private/class-internal))
-(import tc-if^ tc-lambda^ tc-app^ tc-let^ tc-send^ check-subforms^ tc-literal^)
+(import tc-if^ tc-lambda^ tc-app^ tc-let^ tc-send^ check-subforms^ tc-literal^ tc-expression^)
(export tc-expr^)
-;; do-inst : syntax type -> type
-(define (do-inst stx ty)
- (define inst (type-inst-property stx))
- (define (split-last l)
- (let-values ([(all-but last-list) (split-at l (sub1 (length l)))])
- (values all-but (car last-list))))
- (define (in-improper-stx stx)
- (let loop ([l stx])
- (match l
- [#f null]
- [(cons a b) (cons a (loop b))]
- [e (list e)])))
- (match ty
- [(list ty)
- (list
- (for/fold ([ty ty])
- ([inst (in-list (in-improper-stx inst))])
- (cond [(not inst) ty]
- [(not (or (Poly? ty) (PolyDots? ty)))
- (tc-error/expr #:return (Un) "Cannot instantiate non-polymorphic type ~a"
- (cleanup-type ty))]
- [(and (Poly? ty)
- (not (= (syntax-length inst) (Poly-n ty))))
- (tc-error/expr #:return (Un)
- "Wrong number of type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
- (cleanup-type ty) (Poly-n ty) (syntax-length inst))]
- [(and (PolyDots? ty) (not (>= (syntax-length inst) (sub1 (PolyDots-n ty)))))
- ;; we can provide 0 arguments for the ... var
- (tc-error/expr #:return (Un)
- "Wrong number of type arguments to polymorphic type ~a:\nexpected at least: ~a\ngot: ~a"
- (cleanup-type ty) (sub1 (PolyDots-n ty)) (syntax-length inst))]
- [(PolyDots? ty)
- ;; In this case, we need to check the last thing. If it's a dotted var, then we need to
- ;; use instantiate-poly-dotted, otherwise we do the normal thing.
- ;; In the case that the list is empty we also do the normal thing
- (let ((stx-list (syntax->list inst)))
- (if (null? stx-list)
- (instantiate-poly ty (map parse-type stx-list))
- (let-values ([(all-but-last last-stx) (split-last stx-list)])
- (match (syntax-e last-stx)
- [(cons last-ty-stx (? identifier? last-id-stx))
- (unless (bound-index? (syntax-e last-id-stx))
- (tc-error/stx last-id-stx "~a is not a type variable bound with ..." (syntax-e last-id-stx)))
- (if (= (length all-but-last) (sub1 (PolyDots-n ty)))
- (let* ([last-id (syntax-e last-id-stx)]
- [last-ty (extend-tvars (list last-id) (parse-type last-ty-stx))])
- (instantiate-poly-dotted ty (map parse-type all-but-last) last-ty last-id))
- (tc-error/expr #:return (Un) "Wrong number of fixed type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
- ty (sub1 (PolyDots-n ty)) (length all-but-last)))]
- [_
- (instantiate-poly ty (map parse-type stx-list))]))))]
- [else
- (instantiate-poly ty (stx-map parse-type inst))])))]
- [_ (if inst
- (tc-error/expr #:return (Un)
- "Cannot instantiate expression that produces ~a values"
- (if (null? ty) 0 "multiple"))
- ty)]))
-
;; typecheck an identifier
;; the identifier has variable effect
;; tc-id : identifier -> tc-results
@@ -112,43 +53,9 @@
(unless (syntax? form)
(int-err "bad form input to tc-expr: ~a" form))
;; typecheck form
- (let loop ([form* form] [expected expected] [checked? #f])
- (cond [(type-ascription form*)
- =>
- (lambda (ann)
- (let* ([r (tc-expr/check/internal form* ann)]
- [r* (check-below (check-below r ann) expected)])
- ;; add this to the *original* form, since the newer forms aren't really in the program
- (add-typeof-expr form r)
- ;; around again in case there is an instantiation
- ;; remove the ascription so we don't loop infinitely
- (loop (remove-ascription form*) r* #t)))]
- [(type-inst-property form*)
- ;; check without property first
- ;; to get the appropriate type to instantiate
- (match (tc-expr (type-inst-property form* #f))
- [(tc-results: ts fs os)
- ;; do the instantiation on the old type
- (let* ([ts* (do-inst form* ts)]
- [ts** (ret ts* fs os)])
- (add-typeof-expr form ts**)
- ;; make sure the new type is ok
- (check-below ts** expected))]
- ;; no annotations possible on dotted results
- [ty (add-typeof-expr form ty) ty])]
- [(external-check-property form*)
- =>
- (lambda (check)
- (check form*)
- (loop (external-check-property form* #f)
- expected
- checked?))]
- ;; nothing to see here
- [checked? expected]
- [else
- (define t (tc-expr/check/internal form* expected))
- (add-typeof-expr form t)
- (check-below t expected)]))))
+ (define t (tc-expr/check/internal form expected))
+ (add-typeof-expr form t)
+ (check-below t expected)))
(define (explicit-fail stx msg var)
(cond [(and (identifier? var) (lookup-type/lexical var #:fail (λ _ #f)))
@@ -238,7 +145,7 @@
;; application
[(#%plain-app . _) (tc/app/check form expected)]
;; #%expression
- [(#%expression e) (tc-expr/check #'e expected)]
+ [(#%expression _) (tc/#%expression form expected)]
;; syntax
;; for now, we ignore the rhs of macros
[(letrec-syntaxes+values stxs vals . body)
@@ -379,7 +286,7 @@
;; top-level variable reference - occurs at top level
[(#%top . id) (tc-id #'id)]
;; #%expression
- [(#%expression e) (tc-expr #'e)]
+ [(#%expression _) (tc/#%expression form #f)]
;; #%variable-reference
[(#%variable-reference . _)
(ret -Variable-Reference)]
@@ -412,19 +319,9 @@
(unless (syntax? form)
(int-err "bad form input to tc-expr: ~a" form))
;; typecheck form
- (cond
- [(type-ascription form) => (lambda (ann) (tc-expr/check form ann))]
- [else
- (let ([ty (internal-tc-expr form)])
- (match ty
- [(tc-any-results:)
- (add-typeof-expr form ty)
- ty]
- [(tc-results: ts fs os)
- (let* ([ts* (do-inst form ts)]
- [r (ret ts* fs os)])
- (add-typeof-expr form r)
- r)]))])))
+ (let ([ty (internal-tc-expr form)])
+ (add-typeof-expr form ty)
+ ty)))
(define (single-value form [expected #f])
(define t (if expected (tc-expr/check form expected) (tc-expr form)))
View
103 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/tc-expression.rkt
@@ -0,0 +1,103 @@
+#lang racket/unit
+
+(require
+ "../utils/utils.rkt"
+ (typecheck tc-expr-unit signatures tc-app-helper)
+ (types tc-result tc-error utils abbrev)
+ (rep type-rep)
+ (utils tc-utils)
+ (env index-env tvar-env scoped-tvar-env)
+ (private syntax-properties type-annotation parse-type)
+ unstable/syntax
+ racket/match
+ syntax/stx
+ syntax/parse
+ (for-syntax racket/base syntax/parse syntax/parse/experimental/template))
+
+
+(import tc-expr^)
+(export tc-expression^)
+
+(define-syntax define-expression-annotations
+ (syntax-parser
+ ((_ (name:id (attr:id acc:expr) ...) ...)
+ (template
+ (begin
+ (define-syntax-class name
+ #:literal-sets (kernel-literals)
+ (pattern (~and exp #%expression)
+ (?@ #:attr attr (acc #'exp)) ...
+ (?@ #:when (attribute attr)) ...)) ...)))))
+
+(define-expression-annotations
+ (type-inst (vars type-inst-property))
+ (external-check (check external-check-property))
+ (type-ascrip
+ (ty type-ascription)
+ (scoped-vars ascribed-scoped-type-vars)))
+
+
+;; Typecheck an (#%expression e) form
+(define (tc/#%expression form expected)
+ (syntax-parse form
+ [(exp:type-inst e)
+ (do-inst (tc-expr #'e) (attribute exp.vars))]
+ [(exp:type-ascrip e)
+ (add-scoped-tvars #'e (attribute exp.scoped-vars))
+ (tc-expr/check #'e (attribute exp.ty))]
+ [(exp:external-check e)
+ ((attribute exp.check) #'e)
+ (if expected
+ (tc-expr/check #'e expected)
+ (tc-expr #'e))]
+ [(_ e)
+ (if expected
+ (tc-expr/check #'e expected)
+ (tc-expr #'e))]))
+
+
+;; do-inst : syntax? (or/c tc-results/c #f) -> tc-results/c
+(define (do-inst results inst)
+ (when (and inst (not (syntax? inst)))
+ (int-err "Bad type-inst property ~a" inst))
+ (match results
+ [(tc-result1: ty f o)
+ (define new-ty
+ (cond
+ [(not inst) ty]
+ [(not (or (Poly? ty) (PolyDots? ty)))
+ (tc-error/expr "Cannot instantiate non-polymorphic type ~a"
+ (cleanup-type ty))]
+ [(and (Poly? ty)
+ (not (= (syntax-length inst) (Poly-n ty))))
+ (tc-error/expr "Wrong number of type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
+ (cleanup-type ty) (Poly-n ty) (syntax-length inst))]
+ [(and (PolyDots? ty) (< (syntax-length inst) (sub1 (PolyDots-n ty))))
+ ;; we can provide 0 arguments for the ... var
+ (tc-error/expr "Wrong number of type arguments to polymorphic type ~a:\nexpected at least: ~a\ngot: ~a"
+ (cleanup-type ty) (sub1 (PolyDots-n ty)) (syntax-length inst))]
+ [(PolyDots? ty)
+ ;; In this case, we need to check the last thing. If it's a dotted var, then we need to
+ ;; use instantiate-poly-dotted, otherwise we do the normal thing.
+ (match (syntax->list inst)
+ [(list ty-stxs ... (app syntax-e (cons bound-ty-stx (? identifier? bound-id))))
+ (unless (bound-index? (syntax-e bound-id))
+ (tc-error/stx bound-id "~a is not a type variable bound with ..." (syntax-e bound-id)))
+ (if (= (length ty-stxs) (sub1 (PolyDots-n ty)))
+ (let* ([last-id (syntax-e bound-id)]
+ [last-ty (extend-tvars (list last-id) (parse-type bound-ty-stx))])
+ (instantiate-poly-dotted ty (map parse-type ty-stxs) last-ty last-id))
+ (tc-error/expr "Wrong number of fixed type arguments to polymorphic type ~a:\nexpected: ~a\ngot: ~a"
+ ty (sub1 (PolyDots-n ty)) (length ty-stxs)))]
+ [stx-list
+ (instantiate-poly ty (map parse-type stx-list))])]
+ [else
+ (instantiate-poly ty (stx-map parse-type inst))]))
+ (ret new-ty f o)]
+ [(tc-results: ts)
+ (if inst
+ (tc-error/expr #:return (ret -Bottom)
+ "Cannot instantiate expression that produces ~a values"
+ (if (null? ts) 0 "multiple"))
+ results)]))
+
View
4 pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/typechecker.rkt
@@ -7,7 +7,7 @@
"tc-app-combined.rkt"
"tc-if.rkt" "tc-lambda-unit.rkt"
"tc-let-unit.rkt" "tc-apply.rkt"
- "tc-literal.rkt"
+ "tc-literal.rkt" "tc-expression.rkt"
"tc-send.rkt"
"tc-expr-unit.rkt" "check-subforms-unit.rkt")
@@ -15,4 +15,4 @@
(define-values/invoke-unit/infer
(link tc-if@ tc-lambda@ tc-app-combined@ tc-let@ tc-expr@
- tc-send@ check-subforms@ tc-apply@ tc-literal@))
+ tc-expression@ tc-send@ check-subforms@ tc-apply@ tc-literal@))
View
6 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/dead-inf-comp.rkt
@@ -18,9 +18,6 @@ TR info: dead-inf-comp.rkt 204:4 (>= -inf.f rat) -- exact real arith
TR info: dead-inf-comp.rkt 207:4 (>= rat -inf.f) -- exact real arith
TR info: dead-inf-comp.rkt 212:41 displayln -- hidden parameter
TR info: dead-inf-comp.rkt 212:41 displayln -- hidden parameter
-TR opt: dead-inf-comp.rkt 102:0 #%module-begin -- dead else branch
@samth Collaborator
samth added a note

Why does this change affect the optimizer output?

Not sure exactly, but it looks like it is better. The dead else branch was not at the module begin but inside the for loop. My guess is that the #%expression allowed it to find it correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-TR opt: dead-inf-comp.rkt 102:0 #%module-begin -- dead else branch
-TR opt: dead-inf-comp.rkt 102:0 #%module-begin -- dead else branch
TR opt: dead-inf-comp.rkt 108:4 (quote dead) -- dead else branch
TR opt: dead-inf-comp.rkt 110:4 (quote dead) -- dead then branch
TR opt: dead-inf-comp.rkt 113:4 (quote dead) -- dead then branch
@@ -59,6 +56,9 @@ TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (display
TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
+TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
+TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
+TR opt: dead-inf-comp.rkt 212:0 (for: ((i (in-range 5 +inf.0 2)) (j 3)) (displayln i)) -- dead else branch
TR opt: dead-inf-comp.rkt 212:36 3 -- in-range
END
#<<END
View
8 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/pr13468.rkt
@@ -26,11 +26,11 @@ TR opt: pr13468.rkt 146:21 -6.0 -- float-arg-expr in complex ops
TR opt: pr13468.rkt 146:5 (real-part (ann -6.0 Negative-Flonum)) -- unboxed unary float complex
TR opt: pr13468.rkt 147:21 6.0 -- float-arg-expr in complex ops
TR opt: pr13468.rkt 147:5 (real-part (ann 6.0 Flonum)) -- unboxed unary float complex
-TR opt: pr13468.rkt 90:13 6.0+2.3i -- unboxed literal
-TR opt: pr13468.rkt 90:13 6.0+2.3i -- unboxed literal
+TR opt: pr13468.rkt 90:13 6.0+2.3i -- unbox float-complex
+TR opt: pr13468.rkt 90:13 6.0+2.3i -- unbox float-complex
TR opt: pr13468.rkt 90:5 (- (ann 6.0+2.3i Float-Complex)) -- unboxed unary float complex
-TR opt: pr13468.rkt 91:13 6.0+2.3i -- unboxed literal
-TR opt: pr13468.rkt 91:13 6.0+2.3i -- unboxed literal
+TR opt: pr13468.rkt 91:13 6.0+2.3i -- unbox float-complex
+TR opt: pr13468.rkt 91:13 6.0+2.3i -- unbox float-complex
TR opt: pr13468.rkt 91:5 (/ (ann 6.0+2.3i Float-Complex)) -- unboxed unary float complex
END
#<<END
View
40 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/unboxed-for.rkt
@@ -1,25 +1,25 @@
#;#;
#<<END
-TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- call to fun with unboxed args
-TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- fun -> unboxed fun
-TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unbox float-complex
-TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed call site
-TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed call site
-TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed let bindings
-TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed let bindings
-TR opt: unboxed-for.rkt 32:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed let loop
-TR opt: unboxed-for.rkt 32:31 sum -- leave var unboxed
-TR opt: unboxed-for.rkt 32:31 sum -- unbox float-complex
-TR opt: unboxed-for.rkt 32:31 sum -- unboxed complex variable
-TR opt: unboxed-for.rkt 32:31 sum -- unboxed complex variable
-TR opt: unboxed-for.rkt 32:31 sum -- unboxed var -> table
-TR opt: unboxed-for.rkt 32:53 0.0+0.0i -- unboxed literal
-TR opt: unboxed-for.rkt 33:13 i -- unboxed complex variable
-TR opt: unboxed-for.rkt 33:13 i -- unboxed complex variable
-TR opt: unboxed-for.rkt 33:33 (quote (1.0+2.0i 2.0+4.0i)) -- in-list
-TR opt: unboxed-for.rkt 34:11 sum -- leave var unboxed
-TR opt: unboxed-for.rkt 34:6 (+ i sum) -- unboxed binary float complex
-TR opt: unboxed-for.rkt 34:9 i -- leave var unboxed
+TR opt: unboxed-for.rkt 46:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- call to fun with unboxed args
+TR opt: unboxed-for.rkt 46:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- fun -> unboxed fun
+TR opt: unboxed-for.rkt 46:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unbox float-complex
+TR opt: unboxed-for.rkt 46:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed call site
+TR opt: unboxed-for.rkt 46:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed call site
+TR opt: unboxed-for.rkt 46:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed let bindings
+TR opt: unboxed-for.rkt 46:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed let bindings
+TR opt: unboxed-for.rkt 46:0 (for/fold: : Float-Complex ((sum : Float-Complex 0.0+0.0i)) ((i : Float-Complex (quote (1.0+2.0i 2.0+4.0i)))) (+ i sum)) -- unboxed let loop
+TR opt: unboxed-for.rkt 46:31 sum -- leave var unboxed
+TR opt: unboxed-for.rkt 46:31 sum -- unbox float-complex
+TR opt: unboxed-for.rkt 46:31 sum -- unboxed complex variable
+TR opt: unboxed-for.rkt 46:31 sum -- unboxed complex variable
+TR opt: unboxed-for.rkt 46:31 sum -- unboxed var -> table
+TR opt: unboxed-for.rkt 46:53 0.0+0.0i -- unboxed literal
+TR opt: unboxed-for.rkt 47:13 i -- unboxed complex variable
+TR opt: unboxed-for.rkt 47:13 i -- unboxed complex variable
+TR opt: unboxed-for.rkt 47:33 (quote (1.0+2.0i 2.0+4.0i)) -- in-list
+TR opt: unboxed-for.rkt 48:11 sum -- leave var unboxed
+TR opt: unboxed-for.rkt 48:6 (+ i sum) -- unboxed binary float complex
+TR opt: unboxed-for.rkt 48:9 i -- leave var unboxed
END
#<<END
3.0+6.0i
View
2  pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/vector-length.rkt
@@ -1,7 +1,7 @@
#;#;
#<<END
TR opt: vector-length.rkt 15:0 (vector-length (vector 1 2 3)) -- known-length vector-length
-TR opt: vector-length.rkt 16:0 (vector-length (ann (vector 4 5 6) (Vectorof Integer))) -- known-length vector-length
+TR opt: vector-length.rkt 16:0 (vector-length (ann (vector 4 5 6) (Vectorof Integer))) -- vector-length
@samth Collaborator
samth added a note

Why are there fewer optimizations here?

Because the optimizer can no longer see through type annotations. The type of the expression is (Vectorof Integer) not (Vector Integer Integer Integer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
END
#<<END
3
View
142 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/vector-sum.rkt
@@ -1,76 +1,76 @@
#;#;
#<<END
-TR opt: vector-sum.rkt 77:0 #%module-begin -- dead else branch
-TR opt: vector-sum.rkt 77:0 #%module-begin -- dead else branch
-TR opt: vector-sum.rkt 77:0 #%module-begin -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 86:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
-TR opt: vector-sum.rkt 87:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
-TR opt: vector-sum.rkt 88:21 (sin (exact->inexact i)) -- unary float
-TR opt: vector-sum.rkt 88:21 (sin (exact->inexact i)) -- unary float
-TR opt: vector-sum.rkt 88:21 (sin (exact->inexact i)) -- unary float
-TR opt: vector-sum.rkt 88:21 (sin (exact->inexact i)) -- unary float
-TR opt: vector-sum.rkt 88:26 (exact->inexact i) -- fixnum to float
-TR opt: vector-sum.rkt 88:26 (exact->inexact i) -- fixnum to float
-TR opt: vector-sum.rkt 88:26 (exact->inexact i) -- fixnum to float
-TR opt: vector-sum.rkt 88:26 (exact->inexact i) -- fixnum to float
-TR opt: vector-sum.rkt 88:4 (vector-set! v i (sin (exact->inexact i))) -- vector partial bounds checking elimination
-TR opt: vector-sum.rkt 88:4 (vector-set! v i (sin (exact->inexact i))) -- vector partial bounds checking elimination
-TR opt: vector-sum.rkt 88:4 (vector-set! v i (sin (exact->inexact i))) -- vector partial bounds checking elimination
-TR opt: vector-sum.rkt 88:4 (vector-set! v i (sin (exact->inexact i))) -- vector partial bounds checking elimination
-TR opt: vector-sum.rkt 89:15 sum -- dead else branch
-TR opt: vector-sum.rkt 89:15 sum -- dead else branch
-TR opt: vector-sum.rkt 89:15 sum -- dead else branch
-TR opt: vector-sum.rkt 89:15 sum -- dead else branch
-TR opt: vector-sum.rkt 89:15 sum -- dead else branch
-TR opt: vector-sum.rkt 89:15 sum -- dead else branch
-TR opt: vector-sum.rkt 89:15 sum -- dead else branch
-TR opt: vector-sum.rkt 89:15 sum -- dead else branch
-TR opt: vector-sum.rkt 89:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
-TR opt: vector-sum.rkt 89:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
-TR opt: vector-sum.rkt 89:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
-TR opt: vector-sum.rkt 89:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
-TR opt: vector-sum.rkt 89:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
-TR opt: vector-sum.rkt 89:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
-TR opt: vector-sum.rkt 89:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
-TR opt: vector-sum.rkt 89:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
-TR opt: vector-sum.rkt 91:11 (vector-ref v i) -- vector partial bounds checking elimination
-TR opt: vector-sum.rkt 91:11 (vector-ref v i) -- vector partial bounds checking elimination
-TR opt: vector-sum.rkt 91:11 (vector-ref v i) -- vector partial bounds checking elimination
-TR opt: vector-sum.rkt 91:11 (vector-ref v i) -- vector partial bounds checking elimination
-TR opt: vector-sum.rkt 91:4 (+ sum (vector-ref v i)) -- binary float
-TR opt: vector-sum.rkt 91:4 (+ sum (vector-ref v i)) -- binary float
-TR opt: vector-sum.rkt 91:4 (+ sum (vector-ref v i)) -- binary float
-TR opt: vector-sum.rkt 91:4 (+ sum (vector-ref v i)) -- binary float
+TR opt: vector-sum.rkt 102:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
+TR opt: vector-sum.rkt 102:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
+TR opt: vector-sum.rkt 102:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
+TR opt: vector-sum.rkt 102:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
+TR opt: vector-sum.rkt 102:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
+TR opt: vector-sum.rkt 102:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
+TR opt: vector-sum.rkt 102:0 (for ((i (in-range 1))) (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- dead else branch
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
+TR opt: vector-sum.rkt 103:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
+TR opt: vector-sum.rkt 104:21 (sin (exact->inexact i)) -- unary float
+TR opt: vector-sum.rkt 104:21 (sin (exact->inexact i)) -- unary float
+TR opt: vector-sum.rkt 104:21 (sin (exact->inexact i)) -- unary float
+TR opt: vector-sum.rkt 104:21 (sin (exact->inexact i)) -- unary float
+TR opt: vector-sum.rkt 104:26 (exact->inexact i) -- fixnum to float
+TR opt: vector-sum.rkt 104:26 (exact->inexact i) -- fixnum to float
+TR opt: vector-sum.rkt 104:26 (exact->inexact i) -- fixnum to float
+TR opt: vector-sum.rkt 104:26 (exact->inexact i) -- fixnum to float
+TR opt: vector-sum.rkt 104:4 (vector-set! v i (sin (exact->inexact i))) -- vector partial bounds checking elimination
+TR opt: vector-sum.rkt 104:4 (vector-set! v i (sin (exact->inexact i))) -- vector partial bounds checking elimination
+TR opt: vector-sum.rkt 104:4 (vector-set! v i (sin (exact->inexact i))) -- vector partial bounds checking elimination
+TR opt: vector-sum.rkt 104:4 (vector-set! v i (sin (exact->inexact i))) -- vector partial bounds checking elimination
+TR opt: vector-sum.rkt 105:15 sum -- dead else branch
+TR opt: vector-sum.rkt 105:15 sum -- dead else branch
+TR opt: vector-sum.rkt 105:15 sum -- dead else branch
+TR opt: vector-sum.rkt 105:15 sum -- dead else branch
+TR opt: vector-sum.rkt 105:15 sum -- dead else branch
+TR opt: vector-sum.rkt 105:15 sum -- dead else branch
+TR opt: vector-sum.rkt 105:15 sum -- dead else branch
+TR opt: vector-sum.rkt 105:15 sum -- dead else branch
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- dead else branch
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- dead else branch
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- dead else branch
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- dead else branch
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- dead else branch
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- dead else branch
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
+TR opt: vector-sum.rkt 105:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
+TR opt: vector-sum.rkt 107:11 (vector-ref v i) -- vector partial bounds checking elimination
+TR opt: vector-sum.rkt 107:11 (vector-ref v i) -- vector partial bounds checking elimination
+TR opt: vector-sum.rkt 107:11 (vector-ref v i) -- vector partial bounds checking elimination
+TR opt: vector-sum.rkt 107:11 (vector-ref v i) -- vector partial bounds checking elimination
+TR opt: vector-sum.rkt 107:4 (+ sum (vector-ref v i)) -- binary float
+TR opt: vector-sum.rkt 107:4 (+ sum (vector-ref v i)) -- binary float
+TR opt: vector-sum.rkt 107:4 (+ sum (vector-ref v i)) -- binary float
+TR opt: vector-sum.rkt 107:4 (+ sum (vector-ref v i)) -- binary float
END
""
View
2  pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/all-tests.rkt
@@ -10,7 +10,6 @@
"parse-type-tests.rkt" ;; pass
"subst-tests.rkt" ;; pass
"infer-tests.rkt" ;; pass
- "type-annotation-test.rkt" ;; pass
"keyword-expansion-test.rkt" ;;pass
"module-tests.rkt" ;; pass
@@ -35,7 +34,6 @@
remove-tests
overlap-tests
parse-type-tests
- type-annotation-tests
module-tests
fv-tests
contract-tests
View
40 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/type-annotation-test.rkt
@@ -1,40 +0,0 @@
-#lang scheme/base
@samth Collaborator
samth added a note

Why are we dropping these tests?

Because they were broken (in terms of phasing) and didn't offer any more coverage than our typecheck tests of similar programs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-(require "test-utils.rkt"
- (for-syntax scheme/base)
- typed-racket/private/type-annotation
- typed-racket/private/parse-type
- (types abbrev numeric-tower utils)
- (env type-env-structs init-envs)
- (utils tc-utils)
- (rep type-rep filter-rep object-rep)
- (submod typed-racket/base-env/base-types initialize)
- rackunit)
-
-(initialize-type-names)
-
-(provide type-annotation-tests)
-
-(define-syntax-rule (tat ann-stx ty)
- (check-tc-result-equal? (format "~a" (quote ann-stx))
- (type-ascription (let ([ons (current-namespace)]
- [ns (make-base-namespace)])
- (parameterize ([current-namespace ns])
- (namespace-require 'typed-racket/base-env/prims)
- (namespace-require 'typed-racket/base-env/base-types)
- (namespace-require 'typed-racket/base-env/base-types-extra)
- (expand 'ann-stx))))
- ty))
-
-(define (type-annotation-tests)
- (test-suite
- "Type Annotation tests"
- ;; FIXME - ask Ryan
- (tat (ann foo : Number) (ret -Number (make-NoFilter) (make-NoObject)))
- (tat foo #f)
- (tat (ann foo : 3) (ret (-val 3) (make-NoFilter) (make-NoObject)))))
-
-(define-go
- type-annotation-tests)
-
-
-
Something went wrong with that request. Please try again.