From 4ac26e919a1a6b78d2a0d2ca518909a756bcc831 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Sat, 3 May 2014 14:16:17 -0700 Subject: [PATCH] Make standalone annotation use #f instead of #'#f. --- .../typed-racket/base-env/annotate-classes.rkt | 2 +- .../typed-racket/base-env/prims.rkt | 18 ++++++++---------- .../unit-tests/typecheck-tests.rkt | 4 ++++ 3 files changed, 13 insertions(+), 11 deletions(-) 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"