Commit Graph

428 Commits

Author SHA1 Message Date
Asumu Takikawa
8ac4f3d29b Add a few more serialization optimizations 2016-06-21 16:37:17 -04:00
Asumu Takikawa
0c1b71bf32 Lift out definition table lookup for init-envs 2016-06-21 16:37:17 -04:00
Asumu Takikawa
196744e0cd Memoize large types in serialization for init-envs 2016-06-21 16:37:17 -04:00
Asumu Takikawa
773dab2c24 Reimplement environment initialization
Avoids using mzlib/pconvert in favor of a few big match
clauses. This lets us cut out a package dependency and
makes the code easier to understand.

This commit also removes the use of mzlib/pconvert
in the debug printer in favor of just using the type
serialization performed in init-envs.rkt.

In addition, a few optimizations for type serialization
were implemented that cut a few percent off of zo sizes.

Note that this commit regresses for zo sizes for modules
that heavily use GUI classes, but that is fixed in a
future commit.
2016-06-21 16:37:17 -04:00
Brian Lachance
ec0c8516c2 Add types for combinations, in-combinations 2016-06-15 09:58:36 -04:00
Asumu Takikawa
67614198c3 Avoid doing require lifting repeatedly
The redirection for contracted identifiers used to do a
require lift on each use. Instead, only do the lift once
and reuse the identifier.
2016-06-13 16:05:40 -04:00
Asumu Takikawa
78e0100663 Improve contract inlining
TR sometimes inlines contracts instead of defining them
separately in order to cooperate with the contract system's
optimizations. In some cases, this caused TR to compile
duplicated contract definitions. This commit eliminates
this inefficiency.
2016-06-13 14:55:08 -04:00
Asumu Takikawa
bc6e9e80cc Don't use number literal types as contracts
Using = for the comparison doesn't work for TR

Fixes bug in 295a4b7e39
2016-06-13 13:25:51 -04:00
Asumu Takikawa
285a2b796d Add custom equality for simple static contracts
This improves memoization of contracts

Appears to cut about 6-7% of zo size for the math
library.
2016-06-13 04:08:33 -04:00
Asumu Takikawa
295a4b7e39 Simplify flat contracts for Value types
Potentially speeds up contracts checks for
types like False or Boolean.
2016-06-13 04:08:33 -04:00
Chris Jester-Young
6ff74e8c35 Give correct type to in-port when used with custom reader (#367)
* Give correct type to `in-port` when used with custom reader.

Currently, `in-port` returns `(Sequenceof Any)` unconditionally,
which is correct if the given read function is `read` (default
value). However, `(in-port read-line)`, `(in-port read-char)`,
etc. should have more specific types.

* For `in-port`, strip out EOF from the sequence type.
2016-06-07 14:15:04 -04:00
Asumu Takikawa
e39bcc6245 Wrap cast in #%expression to avoid too-early call 2016-06-06 13:20:36 -04:00
AlexKnauth
a846514f28 make cast sound 2016-06-06 13:19:33 -04:00
Asumu Takikawa
f23c07f54a Use the right equality function for parent-of? 2016-06-03 14:55:23 -04:00
Asumu Takikawa
a984281cdc Add first-order checks to simple-result-> contract
Fixes issue #368
2016-06-03 13:49:26 -04:00
Asumu Takikawa
b338fc6b64 Be less conservative about struct overlap
Fixes issue #366
2016-06-01 14:23:13 -04:00
Andrew Kent
c7de819424 fix contract related bugs 2016-05-24 14:07:52 -04:00
Andrew Kent
d66816cf76 use match*/no-order to reduce manual code duplication 2016-05-23 18:13:28 -04:00
Asumu Takikawa
71f17f5cb2 Compute struct intersection more conservatively
Fixes GH issue #205
2016-05-20 16:56:49 -04:00
Asumu Takikawa
43dc59bea2 Restrict struct predicate when parent is mutable
Correctly restrict the struct predicate's filter type when
a parent struct is mutable but the child is not and they both
have polymorphic type variables.

See the discussion in GH issue #205
2016-05-20 16:56:49 -04:00
Asumu Takikawa
e800787773 Don't assume built-in structs are mutable
Doing so adds spurious entries in the type environment for
the setters for these structs, even though the setters are
not defined.
2016-05-20 16:55:23 -04:00
Asumu Takikawa
af8ccae0ff Add comments clarifying struct-desc fields 2016-05-20 16:53:53 -04:00
Andrew Kent
c7a3fb0cf1 rename restrict to intersect
since 'restrict' will now create intersections when there is
a complex relationship between the two types, calling it
'intersect' makes a lot more sense.
2016-05-20 15:21:41 -04:00
Andrew Kent
b4a4c174e4 initial intersection types addition
Adds intersection types as a better way to handle the the case
when restrict cannot structurally intersect two types (e.g. when
you learn within a polymorphic function a variable x of type A
is also an Integer, but we dont know how A relates to Integer).
This allows for non-lossy refinements of type info while typechecking.
2016-05-20 11:34:04 -04:00
WarGrey Gyoudmon Ju
5552101f5b Add some useful type definitions (#356) 2016-05-19 17:49:20 -04:00
Asumu Takikawa
36610e6239 Add missing kw arg of peeking-input-port
Closes issue #355
2016-05-16 12:00:54 -04:00
Asumu Takikawa
19e8efec0f Avoid internal error on mismatched values
Fixes issue #342
2016-05-09 18:03:17 -04:00
Asumu Takikawa
31bf61e333 Remove redundant values checks
These can all be done via check-below later in the
typechecking process
2016-05-09 18:03:17 -04:00
Sam Tobin-Hochstadt
743be67d67 Revert "Have provide: annotate the original identifier as well."
This reverts commit 3f889bcf8c.

Unfortunately, this change is not backwards compatible, as seen in
both DrDr failures and errors reported by Ben Greenman.
2016-05-03 10:41:50 -04:00
Asumu Takikawa
7b92405cb7 Fix base-contracted #%contract-defs handling 2016-04-29 18:06:55 -04:00
Sam Tobin-Hochstadt
3f889bcf8c Have provide: annotate the original identifier as well.
Fixes PR 15292.
2016-04-29 12:41:02 -04:00
Asumu Takikawa
af385d6932 Fix issue #336 2016-04-28 11:29:12 -04:00
Asumu Takikawa
6621bd5b32 Retain srcloc for match*/early 2016-04-28 11:29:12 -04:00
Andrew Kent
f9c5a534d0 filter -> prop
This pull request is largely a renaming effort to clean up the TR codebase. There are two primary things I wanted to change:

1. Replace all occurrences of "filter" with "prop" or "proposition"
   - The word "filter" is a meaningless opaque term at this point in the Typed Racket implementation. If anything, it just adds confusion to why things are the way the are. We should use "proposition" instead, since that's what they actually are.

2. Avoid using "Top" and "Bottom" in both the type and proposition realm.
   - Currently the top type is called Univ and the bottom type is called bottom, while the top proposition is called Top and the bottom proposition is called Bot. This is just unnecessarily confusing, doesn't really line up w/ the user-space names, and doesn't line up with the names we use in TR formalisms. Worse, all of the top types of primitive types---e.g. the type of all structs, StructTop--- use Top, so it is really easy to get confused about what name to use for these sorts of things.

With these issues in mind, I made the following changes to names:

Top -> TrueProp
Bot -> FalseProp
TypeFilter -> TypeProp
NotTypeFilter -> NotTypeProp
AndFilter -> AndProp
OrFilter -> OrProp
-filter t o -> -is-type o t
-not-filter t o -> -not-type o t
FilterSet -> PropSet
NoFilter -> #f
NoObject -> #f
-FS -> -PS
-top -> -tt
-bot -> -ff
implied-atomic? q p -> implies-atomic? p q
filter-rec-id -> prop-rec-id
-no-filter -> -no-propset
-top-filter -> -tt-propset
-bot-filter -> -ff-propset
-true-filter -> -true-propset
-false-filter -> -false-propset
PredicateFilter: -> PredicateProp:
add-unconditional-filter-all-args add-unconditional-prop-all-args
2016-04-25 18:36:12 -04:00
Sam Tobin-Hochstadt
e855755349 Update HISTORY for 6.5. 2016-04-18 17:29:37 -04:00
Alex Knauth
bacc1b3411 Fix type of syntax->list (#348)
* Fix type of syntax->list

to return `(U False (Listof (Syntaxof Any)))` if it can't prove that the input is a syntax-list.

Fixes https://github.com/racket/typed-racket/issues/347
This makes the type `syntax->list` consistent with the type `stx->list` already has.

* Add tests for syntax->list
2016-04-16 20:18:59 -04:00
Vincent St-Amour
b352739131 Always populate type table, regardless of optimizer status.
Closes #343.
2016-04-11 14:43:44 -05:00
Asumu Takikawa
cea5091ee6 Fix struct name in Struct type representation
Closes issue #304
2016-04-07 21:49:50 -04:00
Asumu Takikawa
7e3178798b Update the type of random for ranges
Also simplify redundant cases
2016-04-07 15:23:06 -04:00
Asumu Takikawa
1a11ac53e2 Add typed/racket/random, bump version 2016-04-07 15:03:57 -04:00
Asumu Takikawa
b869f18f1c Make contracted unit tests pass 2016-03-31 11:57:54 -04:00
Sam Tobin-Hochstadt
900d2b0be0 add missing require 2016-03-29 07:24:51 -04:00
Asumu Takikawa
9ec358b665 Update type-table after tc-funapp processing
This makes the tooltip show the more refined function
type after application typechecking. For example, case->
types will be narrowed to the particular case that fits.

Polymorphic function types will be instantiated at the
appropriate type.

Fixes issue #325
2016-03-28 17:53:34 -04:00
Asumu Takikawa
cffad4df74 Move possible-domains/cleanup-type to new file
This avoids circular dependencies in preparation
for adding calls to type-table functions from
tc-app-helper.
2016-03-28 17:53:34 -04:00
Sam Tobin-Hochstadt
7572adb9c2 Fix use of simple-result-> to check the domains.
This broke pict3d, but also disabled some contract checks that
should have been kept.
2016-03-28 17:11:37 -04:00
Asumu Takikawa
812f1a8c79 Add types for box-cas!, unsafe-box*-cas! 2016-03-23 16:02:22 -04:00
Vincent St-Amour
495da1bd1a Bring `tc-#%expression in line with its contract. 2016-03-21 14:21:57 -05:00
Sam Tobin-Hochstadt
8d5d7bea7a Use simple-result-> on [0,3]-arg functions.
The included microbenchmark shows a 2x speedup on 0-argument
functions. Motivated by the sieve benchmark from [Takikawa et al,
POPL 2016].
2016-03-18 17:13:34 -04:00
Asumu Takikawa
49f20aa7ed Fix incorrect function signature
(the standard fish is happy now)
2016-03-18 11:30:05 -04:00
Daniel Feltey
425ff47700 Raise errors when signatures are not in the signature environment while typechecking
Closes #319
2016-03-12 16:39:39 -06:00