Sam Tobin-Hochstadt
838431c176
Add the simple-result->
combinator to Typed Racket.
...
This is used for functions with a single argument imported with
`require/typed`, and avoids unneccessary checks. This produces a
3x speedup on the following benchmark:
#lang racket/base
(module m racket/base
(provide f)
(define (f x) x))
(module n typed/racket/base
(require/typed
(submod ".." m)
[f (-> Integer Integer)])
(time
(for ([x (in-range 1000000)])
(f 1) (f 2) (f 3) (f 4))))
(require 'n)
on top of the previous improvment from using `unsafe-procedure-chaperone`
and `procedure-result-arity`.
2016-01-16 22:27:18 -05:00
Asumu Takikawa
7217e2e531
Fix name argument for dtsi/exec
...
Looks like this got typoed in commit a3ca5aeefc
Closes issue #291
2016-01-15 11:58:38 -05:00
Vincent St-Amour
319e6fd4e1
Stop tracking struct constructors.
...
Was only used by OC, for a now-defunct recommendation.
2016-01-05 15:51:19 -06:00
Sam Tobin-Hochstadt
84d26b91ca
Avoid generating definitions for contracts that are identifiers.
...
This reduces the number of pointless definitions, and re-enables
some contract system optimizations.
2016-01-02 11:46:51 -05:00
Matthew Flatt
cd7d347051
update types of find-files
and pathlist-closure
2016-01-02 07:59:32 -07:00
Vincent St-Amour
2dafb04587
Fix type of dup-output-port.
2016-01-01 16:05:41 -06:00
Vincent St-Amour
40e7c969ab
Refine type of min
.
...
Closes PR14896.
2015-12-31 14:32:41 -06:00
Sam Tobin-Hochstadt
3be139b9b5
Merge branch 'opaque'
2015-12-31 10:53:30 -05:00
Robby Findler
d58d7487e8
port typed-racket contracts to late-neg projections
2015-12-31 08:58:32 -06:00
Alexis King
a3ca5aeefc
Allow the types created for structs to be specified manually
...
This allows the types generated by the struct form, as well as #:struct
clauses of require/typed, to be specified explicitly using a #:type-name
option. This allows the name of a struct and the type it is assigned to
be different.
Closes #261
2015-12-30 13:12:05 -08:00
Sam Tobin-Hochstadt
d3fac7c24a
Revise handling of #:opaque types, and Any.
...
Guard opaque predicates with an (-> Any Any) contract. This uses the
contract generation infrastructure to avoid wrapping struct predicates.
Also, relax `any-wrap/c` (the contract used for `Any` in positive
position) to allow opaque structures. This also requires an enumeration
of all the other kinds of values that TR understands, so that they are
not confused with opaque structures.
Joint work with @bennn.
Closes #202 .
Closes #203 .
Closes #241 .
2015-12-30 12:33:15 -05:00
Georges Dupéron
ce4a2b3d36
Improved error messages given by typed/racket, by always including the type name and arguments in the error message.
...
When a typing error is located inside macro-expanded code, a message such as “wrong number of arguments to polymorphic type: expected 1 and got 2” does not help much in locating which instantiation is wrong.
2015-12-29 17:35:32 -05:00
AlexKnauth
96fd22a7a3
add type for flatten
...
fixes https://github.com/racket/typed-racket/issues/277
Can’t make it polymorphic, settle for `Any -> (Listof Any)`
2015-12-24 10:09:23 -05:00
Asumu Takikawa
b18d940f1a
Fix GH issue #271
...
Propagate syntax properties when opening up begins at the top-level
so that ignore properties will get transferred.
2015-12-18 18:10:48 -05:00
Vincent St-Amour
f9e3418d8a
Only show OC button in DrR when the tool is actually loaded.
...
Closes PR13344.
2015-12-18 15:58:40 -06:00
Sam Tobin-Hochstadt
519dfb6fdc
Handle Sequenceof
in the type parser to support multiple values.
2015-12-17 19:42:29 -05:00
Georges Dupéron
f992786243
Fixes GH issue #268 “Can't provide promise for polymorphic struct”.
...
See also commit 5cd5f77
“Don't allow promises created with `delay/name` as `(Promise T)`.”.
The contracts in `typed-racket-lib/typed-racket/static-contracts/combinators/structural.rkt` should be just a single identifier, not a lambda expression, because `typed-racket-lib/typed-racket/private/type-contract.rkt` relies on that, and passes the contract name to free-identifier=?, which won't work on a lambda.
2015-12-17 14:52:40 +01:00
Matthew Flatt
38e091c1c4
add type for an internal function in a match
expansion
2015-12-09 17:21:56 -07:00
Asumu Takikawa
796af399bf
Support #:constructor-name in TR's struct
2015-12-08 00:33:43 -05:00
Asumu Takikawa
fc809e370e
Add support for #:extra-constructor-name to struct
...
Simplify TR's define-struct to expand to struct
2015-12-08 00:33:06 -05:00
Vincent St-Amour
70afdf6f70
Relax type of expt.
...
Made possible by the fix to its dynamic behavior.
Should be fully backwards compatible.
2015-12-02 15:44:23 -06:00
Sam Tobin-Hochstadt
600935aae1
Don't report duplicate error messages.
2015-12-02 11:00:47 -05:00
Sam Tobin-Hochstadt
9c1569646e
Construct syntax to be checked with source locations.
...
Closes #258 .
2015-12-01 14:22:16 -05:00
Sam Tobin-Hochstadt
ab4514bb56
Use symbols instead of identifiers for poorly-printing struct types.
...
This case only comes up when something else unfortunate has happened
with type printing, but the current implementation can lead to paths
in the type printing.
2015-11-30 17:55:26 -05:00
Vincent St-Amour
781e0504bb
Type of expt was overly optimistic.
2015-11-29 15:47:33 -06:00
Andrew Kent
581469e749
removed scope structs from types
2015-11-28 15:04:03 -05:00
Matthew Flatt
c4f39433e1
refine the type of collect-garbage
...
The `collect-garbage` function now accepts a mode argument.
2015-11-27 06:57:37 -07:00
Vincent St-Amour
6a8c366210
Fix type of expt
to reflect fix to dynamic behavior.
2015-11-25 17:33:00 -06:00
Vincent St-Amour
fe4808f96a
Fix magnitude on numbers with negative components.
...
Closes PR 15183.
2015-11-23 14:30:20 -06:00
Sam Tobin-Hochstadt
9fc2c5b3c3
Fix mutated variable handling at the top level.
2015-11-18 13:16:41 -05:00
Sam Tobin-Hochstadt
577ab41da6
Keep ignored provide forms in the output.
...
Closes #231 .
2015-11-16 09:45:08 -05:00
Sam Tobin-Hochstadt
0e23bb48cb
Add missing file.
2015-11-14 20:49:30 -05:00
Sam Tobin-Hochstadt
71b6fc456c
Progress towards deterministic TR compilation.
...
Traverse many dictionaries in sorted order when generating
residual code.
Closes racket/racket#1138 .
2015-11-14 20:32:05 -05:00
Vincent St-Amour
1e32397658
Refine type for expt.
...
Fixes rsound.
2015-11-13 10:14:39 -06:00
Vincent St-Amour
1187281bf7
Fix sign propagation in some real-complex corner cases.
...
May have been found using random testing a while back.
2015-11-12 16:08:20 -06:00
Vincent St-Amour
fb3dee24db
Avoid double coercion.
2015-11-12 16:01:21 -06:00
Vincent St-Amour
b88b4a8829
Fix magnitude opt to not overflow.
...
May have been found with random testing, a while ago.
2015-11-12 15:36:44 -06:00
Vincent St-Amour
53e501bb8b
Avoid generating contraints for optimized-away contract definitions.
...
Closes #214 .
2015-11-12 13:46:37 -06:00
Eric Dobson
c9db5dded7
Make infer/dotted instantiate the dotted variable to improve inference.
...
With this we don't need to infer the length of the dotted variable,
in parts of the inference.
Closes #120 .
2015-11-10 16:56:14 -05:00
Spencer Florence
e0cbc15625
fix a bug where cover+tests could call syntax-local-introduce
when not transforming
...
Closes #204 .
2015-11-10 16:32:09 -05:00
Sam Tobin-Hochstadt
6cbd6d872f
Remove obsolete comment.
2015-11-10 13:24:52 -05:00
Sam Tobin-Hochstadt
93507eb519
Avoid doing too much duplicate typechecking work.
2015-11-10 13:23:39 -05:00
Sam Tobin-Hochstadt
aa969302f8
Avoid typechecking multiple times when handling eta expansions.
2015-11-10 12:34:14 -05:00
Sam Tobin-Hochstadt
d9e3c2ac6a
Repair da574a4
again.
2015-11-10 08:59:18 -05:00
Sam Tobin-Hochstadt
983b509f2a
Repair da574a4
.
2015-11-09 23:28:00 -05:00
Sam Tobin-Hochstadt
da574a47d0
Handle in-vector
with range arguments.
...
* Add `normalise-inputs` to special function env.
* Treat eta-expansion specially. Now
`(lambda (x ...) (f x ...))`
will typecheck like `f` but with a type restricted to
the size of `x ...`.
Currently, this special case only works for non-polymorphic
functions.
2015-11-09 19:04:14 -05:00
ben
5d4477d08d
safe & efficient (-> Any Boolean) contract
...
New strategy for compiling the (-> Any Boolean) type to a contract.
When possible, uses `struct-predicate-procedure?` instead of
wrapping in `(-> any-wrap/c boolean?)`.
Makes exceptions for untyped chaperones/impersonators over struct predicates;
those are always wrapped with `(-> any-wrap/c boolean?)`.
This change also affects (require/typed ... [#:struct ...]), but not #:opaque
2015-11-09 19:04:02 -05:00
Georges Dupéron
67bd07a84a
Fixes type of member
and assoc
, plus some tests for them. See github bug #223 : “(member) has wrong type, exploiting the hole causes segfault”.
2015-11-09 19:04:02 -05:00
Vincent St-Amour
65b6d3e019
Abstract over operations properly.
...
Found using random testing.
2015-11-09 17:16:10 -06:00
Vincent St-Amour
7346abf91c
Preserve sign better in real-complex ops.
...
Found using random testing.
2015-11-09 17:16:10 -06:00
Vincent St-Amour
d91d89ffc1
Improve code gen for real-complex division.
2015-11-09 17:16:10 -06:00
Vincent St-Amour
db79beaf12
Actual fix for not suppressing divide-by-0 errors.
2015-11-09 17:16:10 -06:00
Vincent St-Amour
623a29eff4
Avoid dependency between non-float and is-real properties.
2015-11-09 17:16:10 -06:00
Vincent St-Amour
36a39f7e5d
Simplify interface.
2015-11-09 17:16:10 -06:00
Vincent St-Amour
d50ccec0b9
Revert div-by-0 fix. Breaks other things.
2015-11-09 17:16:10 -06:00
Vincent St-Amour
63e26cf17a
Avoid suppressing divide-by-0 errors.
2015-11-09 17:16:09 -06:00
Vincent St-Amour
6a2c8ca9f7
Fix the fix to flexpt.
2015-11-09 17:16:09 -06:00
Vincent St-Amour
5fe4e6b03f
Add missing coercion.
2015-11-09 17:16:09 -06:00
Vincent St-Amour
0b2ae25c92
Propagate fix to division.
...
Found using random testing, at least twice.
2015-11-09 17:16:09 -06:00
Vincent St-Amour
7ef06f74c9
Extend this handling to multiplication.
...
Found using random testing.
2015-11-09 17:16:09 -06:00
Vincent St-Amour
b101d396a3
Avoid premature float conversions.
...
Found using random testing.
2015-11-09 17:16:09 -06:00
Vincent St-Amour
7ba1ab6e51
Use correct imaginary binding.
...
Fixes 13 bugs found using random testing.
2015-11-09 17:16:09 -06:00
Vincent St-Amour
f523fb1721
Recognize as real values that are not immediately consumed.
...
Fixes 18 bugs found via random testing.
2015-11-09 17:16:09 -06:00
Vincent St-Amour
9385f6e350
Yet another fix for expt and complexes.
...
Found using random testing. Found once.
2015-11-09 17:16:08 -06:00
Vincent St-Amour
5ce00a90d2
Fix sign property of n-ary division.
...
Found using random testing. Found 4 times.
2015-11-09 17:16:08 -06:00
Vincent St-Amour
23de6a654e
Fix another NaN case in expt.
...
Found using random testing. Found 3 times.
2015-11-09 17:16:08 -06:00
Vincent St-Amour
3ef8fe1739
Fix type of expt for bignums that get converted to infinity.
...
Found using random testing. Found 10 times.
2015-11-09 17:16:08 -06:00
Vincent St-Amour
a0ef6b1d8c
Fix type of expt.
...
Found using random testing. Found 10 times.
2015-11-09 17:16:08 -06:00
Vincent St-Amour
16a18d7648
Fix type of flexpt.
...
Found using random testing. Found 9 times.
2015-11-09 17:16:08 -06:00
Alex Knauth
43dc7632d4
don't provide Unit from typed/racket/base
2015-11-05 17:14:35 -05:00
Alex Knauth
390dc3a2b1
provide Unit from typed/racket/unit
2015-11-05 17:14:35 -05:00
Vincent St-Amour
2e100bcb33
Remove unsafety altogether.
...
The bytecode optimizer can do the same transformation.
2015-11-03 20:11:46 -06:00
Vincent St-Amour
2881cffdc2
Simplify unsafe op usage.
2015-11-03 18:27:20 -06:00
Vincent St-Amour
89a06cfae6
Fix bitwise-and on negative numbers.
...
Found using random testing.
2015-11-03 16:02:05 -06:00
Vincent St-Amour
58e97f83ea
Fix sign propagation for division.
...
Found using random testing.
2015-11-03 15:47:32 -06:00
Vincent St-Amour
207a12fa23
Fix the fix to compound pair optimimzations.
...
Previous version could drop code on the ground in some cases.
2015-11-03 14:35:32 -06:00
Vincent St-Amour
8f32aad3ee
Remove not-actually-unsafe unsafe operations.
2015-11-03 14:34:39 -06:00
Vincent St-Amour
5b57736af6
Guard some unsafe ops.
2015-11-03 14:32:23 -06:00
Vincent St-Amour
59b5cb7346
Remove unused dependency.
2015-11-03 14:25:49 -06:00
Vincent St-Amour
f14793c462
Remove potentially incorrect unsafe operation.
2015-11-03 14:11:49 -06:00
Vincent St-Amour
da97da5ff8
Fix type of expt when mixing floats and float complexes.
...
Found using random testing.
2015-11-02 19:31:00 -06:00
Vincent St-Amour
ca9306bb1d
Use more precise notion of "real argument" for multiplication too.
...
Found using random testing.
2015-11-02 19:31:00 -06:00
Vincent St-Amour
e47ffeb0e8
Fix interaction of sign and underflow in fl/.
...
Found using random testing.
2015-11-02 19:31:00 -06:00
Vincent St-Amour
a3d29d9e03
Align float-complex/float division with Racket more.
...
Found using random testing.
2015-11-02 19:30:59 -06:00
Sam Tobin-Hochstadt
ad0c69ea29
Make these definitions safe again.
...
As of this moment, the performance win on new-metrics.rkt for
using the unsafe version is about 1% (avg over 10 runs), which
isn't enough to make it worth the segfaults. I believe that
changes to the JIT since 2012 (when the unsafe ops were added)
have sped up struct access.
2015-11-02 14:49:25 -05:00
Vincent St-Amour
ea6968f1d9
Don't attempt to unfold pair opts when we have no type info.
...
Fixes compilation of the `midi-readwrite` package.
2015-11-02 13:28:22 -06:00
Asumu Takikawa
ae0741aaa7
Use cond-contract forms instead of lazy-require
2015-10-31 04:15:06 -04:00
Asumu Takikawa
47ba1391f5
Add begin-for-cond-contract
2015-10-31 04:15:06 -04:00
Asumu Takikawa
0be2156521
Remove unused lazy-requires
2015-10-31 04:15:06 -04:00
Asumu Takikawa
15aa3d875f
Delete top-level hack that's no longer necessary
...
The trampolining implementation of the top-level solves this
without the dependency on rep/type-rep.rkt
2015-10-31 02:32:42 -04:00
Asumu Takikawa
a24852548a
Adjust expansion of contract submod redirection
...
The `local-expand` based trick defeats optimizations for the
contract system because of the extra `let-values` that's
introduced, so use `syntax-local-lift-require` instead.
This commit combined with the previous commit improves
the performance of the test at
typed-racket-test/performance/function-contract.
by a significant amount back to v6.1.1 performance.
Thanks to Robby for discovering the regression.
2015-10-29 17:50:18 -04:00
Asumu Takikawa
555571c268
Inline ->* contracts in type->contract generation
...
The contract generation process was aggressively optimizing
some contracts, leading to a pessimization when interacting
with the contract system's own optimizations.
This inlining addition undoes a small portion of the contract
generation in some cases to better cooperate with the contract
system's optimizations.
This commit alone doesn't solve the optimization problem.
But it does when combined with the next commit.
2015-10-29 17:50:18 -04:00
Asumu Takikawa
0d4b2fb3f7
Refactor define-values
for contract definition
...
This worked by accident and added an extraneous function
definition and call. Refactor to avoid that.
2015-10-29 17:50:18 -04:00
Daniel Feltey
d7ae7dbdd8
Fix incorrect serialization of signature environment
...
Closes #229
2015-10-29 01:35:33 -05:00
Asumu Takikawa
ac880411d4
Memoize the Un constructor for unions
...
This seems to speed up typechecking by 5-10% (depending
on the machine) on compiling the math library and on
the "new-metrics.rkt" test.
2015-10-24 21:39:43 -04:00
Sam Tobin-Hochstadt
c8ea37c64e
Add error message for incorrect use of Parameterof
.
...
Closes PR 14417.
2015-10-23 15:40:31 -04:00
Asumu Takikawa
2479dffde0
Fix #:opaque require clauses at the top-level
2015-10-21 17:23:24 -04:00
Asumu Takikawa
5fa40de546
Avoid ignoring class/unit forms at the top-level
...
Possibly a better long-term solution (for after the release)
is to not use the ignore property here and instead just use the
ignore table.
2015-10-21 13:33:30 -04:00
Asumu Takikawa
c3a59ee1c4
Use protect-out
for unsafe operations
...
Disallows usage in sandboxes and similar contexts
2015-10-20 18:00:35 -04:00
Sam Tobin-Hochstadt
6aa635d740
Fix equality handling on literals.
...
Repairs eb93a2b571
and closes #215 .
2015-10-20 15:56:07 -04:00