From 5f0b741571bdafba6204c86bfc67a11ecca5b814 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 20 Oct 2014 02:50:24 -0400 Subject: [PATCH] Fix a bug in typechecking kw function application Mandatory kw arguments in function types could confuse the typechecker when the function had the `syntax-procedure-converted-arguments-property` property set. original commit: a70588ac4fa27fc7c69b8901be8f129802db05d7 --- .../typed-racket/types/kw-types.rkt | 8 +++--- .../succeed/keyword-function-order.rkt | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/succeed/keyword-function-order.rkt diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/kw-types.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/kw-types.rkt index 6c025acc..74f9f964 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/kw-types.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/kw-types.rkt @@ -28,12 +28,10 @@ (define ts (flatten (list - (for/list ([k (in-list mand-kw-t)]) + (for/list ([k (in-list kw-t)]) (match k - [(Keyword: _ t _) t])) - (for/list ([k (in-list opt-kw-t)]) - (match k - [(Keyword: _ t _) (list (-opt t) -Boolean)])) + [(Keyword: _ t #t) t] + [(Keyword: _ t #f) (list (-opt t) -Boolean)])) plain-t (for/list ([t (in-list opt-t)]) (-opt t)) (for/list ([t (in-list opt-t)]) -Boolean) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/succeed/keyword-function-order.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/succeed/keyword-function-order.rkt new file mode 100644 index 00000000..974d78f9 --- /dev/null +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/succeed/keyword-function-order.rkt @@ -0,0 +1,26 @@ +#lang racket/base + +;; Tests for keyword ordering issues with mandatory keyword +;; arguments + +(module a racket + (define (f a #:w [w "w"] #:x x #:y [y "y"]) x) + (provide f)) + +(module b typed-racket/base-env/extra-env-lang + (require (submod ".." a)) + (type-environment + [f (->key -Symbol + ;; this alphabetic ordering of keywords should + ;; be preserved in the kw type conversion for applications, + ;; rather than separating mandatory/optional as for lambdas + #:w -String #f + #:x -Symbol #t + #:y -String #f + -Symbol)])) + +(module c typed/racket + (require (submod ".." b)) + (f 'a #:x 'x)) + +(require 'c)