typed-racket/typed-racket-test
Eric Dobson 3b80ae71f9 correct keyword function conversion
Keyword functions are a little tricky. This PR addresses issues
checking the body of kw functions.

Basically, a function with keyword arguments such as inc:

(define (inc x #:n [n 1])
  (+ x n))

actually expands into a more complex function with 3 arguments that
looks something resembling the following:

(define (inc-expanded n* n-given? x)
   (let ([n (if n-given? n* 1)]) (+ x n)))

and calls to inc are converted to match this form:

(inc 42) => (inc-expanded #f #f 42)

(inc 42 #:n 2) => (inc-expanded 2 #t 42)

Note that each optional keyword argument has a boolean flag argument
that signals whether or not the caller provided that keyword argument.

This PR takes advantage of the observation that the value for the n*
argument in inc is only reachable in code when n-given? is #t, and so,
assuming the kw-expansion protocol always only accesses n* if n-given?
is #t, we can actually safely check the body of the function against
the following simple but correct type:

(-> Number Boolean Number Number)

An alternative previous approach expanded the function type into every
possible combination of optional argument and optional argument flag,
but this was prohibitively expensive.
2017-01-07 12:36:01 -05:00
..
fail correct keyword function conversion 2017-01-07 12:36:01 -05:00
gui/succeed Fix first-order check for TR's opaque object/c 2015-03-13 16:52:34 -04:00
optimizer Fix another test for new for expansion. 2016-12-14 15:19:42 -06:00
performance remove interning for most Reps in TR 2016-12-16 15:18:50 -05:00
succeed in-query returns a sequence of single value (#468) 2017-01-06 11:34:54 -05:00
unit-tests use bits for base unions, make unions deterministic 2017-01-05 20:45:17 -05:00
xfail Adjust tests since opaque structs are no longer accepted by Any. 2016-07-09 21:22:08 -04:00
historical-counterexamples.rkt More drdr-found counterexamples. 2015-11-09 17:24:12 -06:00
info.rkt Add syntax for poly structs in require/typed 2016-07-21 12:00:08 -04:00
LICENSE.txt Remove extra directories. 2014-12-02 00:53:36 -05:00
main.rkt Fix accidentally-committed debugging code. 2016-06-24 09:15:28 -04:00
nightly-run.rkt Reduce directory nesting for tests. 2014-12-16 10:07:25 -05:00
places.rkt Rename open-place to place/context. 2015-07-28 16:15:08 -05:00
random-real.rkt Use math/flonum instead of unstable/flonum. 2015-08-27 14:14:51 -05:00
run.rkt Reorganize the TR testing files, and add progress output. 2015-12-29 16:43:25 -05:00
send-places.rkt Reduce directory nesting for tests. 2014-12-16 10:07:25 -05:00
test-docs-complete.rkt Reduce directory nesting for tests. 2014-12-16 10:07:25 -05:00
tr-random-testing.rkt Be more robust against one of {TR,R} erroring. 2015-11-10 16:39:18 -06:00
with-tr-contracts.rkt Fix more collection paths. 2014-12-18 09:30:17 -05:00