diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/annotate-classes.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/annotate-classes.rkt index d50cc9078b..535a43ec01 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/annotate-classes.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/annotate-classes.rkt @@ -152,7 +152,7 @@ #:with ty #'t)) (define-splicing-syntax-class optional-standalone-annotation (pattern (~optional a:standalone-annotation) - #:with ty (if (attribute a) #'a.ty #f))) + #:attr ty (if (attribute a) #'a.ty #f))) (define-syntax-class type-variables #:attributes ((vars 1)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt index 55bf0c24ca..56d33cbde3 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/prims.rkt @@ -888,7 +888,7 @@ This file defines two sorts of primitives. All of them are provided into any mod #,(loop #'(rest ...))))])))])) (define-for-syntax (maybe-annotate-body body ty) - (if (syntax-e ty) + (if ty (type-ascription-property body ty) body)) @@ -905,13 +905,11 @@ This file defines two sorts of primitives. All of them are provided into any mod clause:for-clauses c ...) ; c is not always an expression, can be a break-clause (maybe-annotate-body - (quasisyntax/loc stx - (#,name - (clause.expand ... ...) - #,@(maybe-annotate-body - #'(c ...) - #'a.ty))) - #'a.ty)]))) + (quasisyntax/loc stx + (#,name + (clause.expand ... ...) + c ...)) + (attribute a.ty))]))) (define-syntax (define-for-variants stx) (syntax-parse stx [(_ (name untyped-name) ...) @@ -1004,7 +1002,7 @@ This file defines two sorts of primitives. All of them are provided into any mod (quasisyntax/loc stx (#,name (clause.expand ... ...) c ...)) - #'a.ty)]))) + (attribute a.ty))]))) (define-syntax (define-for*-variants stx) (syntax-parse stx [(_ (name no-colon-name) ...) @@ -1069,7 +1067,7 @@ This file defines two sorts of primitives. All of them are provided into any mod clause:for-clauses c ...) ; c is not always an expression, can be a break-clause (cond - [(syntax-e #'a.ty) + [(attribute a.ty) ;; ty has to include exact 0, exact 1, null (sum/product/list respectively), ;; the initial value of the accumulator ;; (to be consistent with Racket semantics). diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt index 0d3dcecdf2..8b28260bd7 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/typecheck-tests.rkt @@ -2906,6 +2906,10 @@ -Symbol #:expected (ret -Symbol)] + [tc-e + (ann (for/list ([z #"foobar"]) (add1 z)) (Listof Integer)) + (-lst -Int)] + ) (test-suite "tc-literal tests"