Commit Graph

4545 Commits

Author SHA1 Message Date
WarGrey Gyoudmon Ju
e72f2506df Add typed/images/compile-time.rkt (#476) 2017-01-04 17:02:42 -05:00
Benjamin Greenman
b9b3e1a9b9 add typed/file/glob (#440)
* add typed/file/glob

* [typed/file/glob] remove unsafe-provide
2017-01-04 16:48:36 -05:00
Phil Nguyen
2bb0698388 add types for hash-clear, hash-clear!, and hash-copy-clear (#466) 2017-01-04 15:16:49 -05:00
WarGrey Gyoudmon Ju
5b546e1b2c Add type annotations for port line counting (#479) 2017-01-04 14:47:44 -05:00
WarGrey Gyoudmon Ju
fdb79d9a34 Add type annotation for (vector-set-performance-stats) (#480) 2017-01-04 14:47:25 -05:00
Sam Tobin-Hochstadt
565f7ec233 Fix range type after racket/racket#1558.
Closes racket/racket#1560.
2017-01-04 14:29:00 -05:00
Andrew Kent
3e13359ef3 fix errors from 8e7f390 2016-12-20 12:36:26 -05:00
Andrew Kent
be155fa3e3 propagate expected type info further down AST
Previously expected propositions were erased frequently
(at lets and ifs) and checking for logical entailment
was unidirectional instead of bidirectional. In other words,
instead of checking if propositions held at the leaves
of the AST, we would typecheck the AST and blindly propagate
up ALL logical info we learned at each step. This meant that
we would get exponential blow up of propositions even when
we didn't care about their content.

With this commit, instead now we send down expected types
*and* propositions so we can verify expected types and
propisitions are satisfied at leaves, thereby relieving the
need to constantly report up huge amounts of logical info
while typechecking.
2016-12-20 07:43:21 -05:00
Andrew Kent
aa1d36f44e add type syntax for Union/Intersection 2016-12-19 20:16:36 -05:00
Andrew Kent
da30fb6f74 be less eager about bottom propogation
Moving to eager propagating of bottom works for most cases,
but in some cases flattening types such as (Pairof Bottom Any)
to Bottom made things like type inference break for some cases
(since (Listof Nothing) == Null, and (Listof A) did not structurally
like up like it used to). Perhaps w/ a little more effort
inference and any other potential issues could work better
with propagating bottom, but for now we'll be slightly less
aggressive about it.

i.e. this fixes pfds, which commit 8e7f390 broke.
2016-12-19 08:28:49 -05:00
Andrew Kent
708e0782fa make name table non-weak 2016-12-16 22:36:02 -05:00
Andrew Kent
09b78c6ab2 remove unneeded nondeterminism 2016-12-16 22:35:30 -05:00
Andrew Kent
8e7f39025a remove interning for most Reps in TR
Prior to this change (which was Typed Racket PR 469) all internal TR
objects (Reps) were interned and kept around for the entire duration
of type checking.  Because of this, frequent operations that rebuilt
types were particularly costly (e.g. various forms of
substitution). To recoup some of this cost, caching was being used in
a lot of places. This PR sought to remove interning as the default
behavior for Reps and allow for more flexibility in how we approach
time/space performance needs going forward.

The following changes were included in this overhaul:

Interning: All Reps are no longer interned. Right now we only intern
unions and some propositions.

Rep generic operations: we now use racket/generic so we're not
reinventing this wheel.

Singletons: Reps (e.g. TrueProp, Univ, etc) can be declared singleton,
which creates a single instance of the rep that all visible operations
(even within the declaring module) are defined in terms of
(e.g. predicates are defined as (λ (x) (eq? x singleton-instance)),
etc).

Custom constructors: Custom constructors can be specified for Reps,
which allows for simple normalization, interning, or other invariants
to be enfored whenever a Rep is created.

Union: Unions used to try to ensure no obviously overlaping types
would inhabit the same Union (e.g. (U String (Pairof Any Any) (Pairof
Int Int)) would be simplified to (U String (Pairof Any Any))). This,
however, required frequent calls to subtyping every time a Union was
modified and working with Unions thus had a high cost (another thing
that caching was used to reduce). Instead of this, Unions now enforce
a much simpler set of invariants on their members: (1) No duplicates
(by virtue of using a hash-based set), (2) Any and Nothing do not
appear in unions, and (3) Nested unions are flattened. Also, using a
hashset as the internal data structure meant that we could easily
intern unions w.r.t. equal? equality. NOTE: we do reduce unions to not
contain obviously overlapping terms when printing to users and when
generating contracts (so obviously and avoidable inneficient contracts
are not generated – See union.rkt for 'normalize-type').

Subtyping changes: Subtyping has been designed to reduce dispatch time
w/ a switch since we no longer cache _all_ subtyping calls (we only
cache subtyping results for unions since they have some costly
subtyping).

prop-ops changes: AndProps now are careful to sort OrProps by length
before building the resulting proposition. This is done because
OrProp implication only checks if one Or is a subset of another Or.
By ordering Or props by size, we only ever check if an OrProp implies
another if its size is <= the other OrProp. This also makes the
smart constructor '-and' more robust, since the order the props
appear does not affect if some Ors are kept or not.

Testing: More subtype tests have been added (we are still probably
relying too much on typecheck-tests.rkt and not the more granular unit
tests in general).  Also, typecheck-tests.rkt has been changed to
check for type-equivalence (i.e. subtyping in both directions)
instead of equal? equivalence.
2016-12-16 15:18:50 -05:00
WarGrey Gyoudmon Ju
90a4d73414 Add typed/setup/getinfo (#472) 2016-12-15 16:51:33 -05:00
Vincent St-Amour
859d9f9eee Fix another test for new for expansion.
The new expansion actually helps us avoid a spurious unboxing.
2016-12-14 15:19:42 -06:00
Vincent St-Amour
60ba1c4447 Fix tests for new expansion of for. 2016-12-14 14:36:15 -06:00
Matthew Flatt
0be76c5537 sync with change to for expansion
The expansion of `for` for a generic sequence has changed to receive
and use an extra result from the internal `make-sequence` function.
2016-12-13 20:04:29 -07:00
Vincent St-Amour
67bf3db5b8 Fix test for improved syntax-parse optimization. 2016-12-13 14:23:34 -06:00
Tim Brown
d97243b1e8 Update base-env-numeric.rkt (#464)
Added `-Index` to second `varop` list for max so that max is typed for: `(-> Index * Index))`
2016-12-01 09:16:15 -05:00
Sam Tobin-Hochstadt
6a57af77b7 Improve type for dump-memory-stats. 2016-11-28 12:01:07 -05:00
WarGrey Gyoudmon Ju
1c3a0a1f34 improvement: (get-display-backing-scale) returns Positive-Real (#462) 2016-11-27 12:43:49 -05:00
Andrew Kent
7b6013272b fix contract bug 2016-11-22 11:05:43 -05:00
Andrew Kent
f9385af461 clean up tc-let-unit
This commit cleans up some helper functions that have been
pretty awful for a while. The code is (hopefully) more readable
and it does less work (i.e. unneeded substitutions are no longer
performed).
2016-11-21 19:49:33 -05:00
Sam Tobin-Hochstadt
0678743e3d Fix errors in a9ae85d3. 2016-11-05 20:02:15 -04:00
Sam Tobin-Hochstadt
a9ae85d3fd Fix #378 more comprehensively. (#453)
The previous fix relied on finding and manipulating all dead code.
But we missed some; in particular code of the form:

    (begin (error 'x) ...dead...)

So switch to a different strategy that tolerates untraversed
dead code.
2016-11-05 13:11:25 -04:00
Stephen Chang
6cdc59aa9f typed racket doc typo 2016-11-03 15:55:22 -04:00
Andrew Kent
6f1eff8d2a less dynamic dispatch in contract gen 2016-10-31 12:53:48 -04:00
Phil Nguyen
a8b20d87aa simplify hash-count's type 2016-10-28 17:15:00 -04:00
Phil Nguyen
c85515e258 type for hash-empty? 2016-10-28 00:19:09 -04:00
Andrew Kent
9c33a54c6a fix intersect, make it (hopefully) commutative 2016-10-25 19:25:28 -04:00
Andrew Kent
db1e7183aa provide less from type-rep 2016-10-24 14:56:44 -04:00
Andrew Kent
9df3a1dab5 fix resolve for names being defined 2016-10-23 21:47:00 -04:00
Andrew Kent
4bfebbda98 fix contract provide ordering bug 2016-10-23 19:50:24 -04:00
Sam Tobin-Hochstadt
a396880bda 6.7 HISTORY. 2016-10-23 17:27:52 -04:00
Andrew Kent
40143109ec remove contract overhead from static-contract code 2016-10-22 19:50:06 -04:00
Andrew Kent
24c64e9de0 new representation scheme for typed racket internals
This is a major to some of the internal representation of things
within Typed Racket (mostly affecting structs that inherited from Rep
(see rep/rep-utils.rkt)), and lots of tweaks and bug fixes that
happened along the way.

This PR includes the following major changes:

A new rep-utils implementation, which uses struct properties for the
generic operations and properties of the various Reps (see
rep-utils.rkt)

More specific Rep inheritance (i.e. arr no longer inherits from Type,
because it is not a Type, etc ...) (see type-rep.rkt, core-rep.rkt,
values-rep.rkt), and thus things like Type/c no longer exist

New Rep's to classify the things that are no longer Type or Prop,
(such as PropSets, SomeValues, Results, etc -- see core-rep.rkt and
values-rep.rkt)

uses of type-case now replaced by uses of Rep-fold and Rep-walk

structural types can specify their fields' variance and operations
like subtyping and free-vars can generically operate over these types
(see type-rep.rkt)

type-mask replaces types key -- types masks are described in detail in
(rep/type-mask.rkt)

Types can specify a predicate to recognize their "top type" via [#:top
pred])

There is an explicit 'Bottom' type now (i.e. neither union or
intersection are used)

subtyping re-organized, slight tweaking to inference

various environments got for-each functions in addition to the map
functions they had (e.g. type-name-env.rkt)

Empty is no longer an Object? -- the OptObject? predicate checks for
either Object or Empty, and so it is easier to be clear about where
Empty makes sense appearing and where it does not

Previously signatures were created with promises in their fields, now
we create a promise around each signature (this way the contracts for
Signature fields are cleaner)

Names for structs now use the args field to describe how many type
arguments they take (Note: this could use further tidying for sure!)

simplified the propositional logic code in several places, got rid of
escape continuations, etc (see prop-ops.rkt, tc-envops.rkt,
tc-metafunctions.rkt)

we now use subsumption more to simplify type results from type
checking, e.g. if the type does not overlap w/ false, it's false
proposition is FalseProp, etc (see tc-expr-unit.rkt and prop-ops.rkt,
the function is called reduce-tc-results/subsumption)

updating along a path will now intersect with the expected structural
type if it is not encountered (e.g. updating Any with (Int @ car) now
produces (Pairof Int Any) instead of Any -- see update.rkt)

lots of tests were tweaked to match up w/ the new prop subsumption
that occurs

remove was renamed subtract (so as to not conflict w/ racket/base's
remove)

a restrict function was added, which acts like intersect but is never
additive (i.e. it will never create an intersection if it can't figure
out how the two types relate -- see intersect.rkt)

tc-subst was modified to substitute out all the variables leaving
scope at once (and I simplified/tweaked some of the logic in there a
little, see tc-subst.rkt)

Type checking function applications now propagates information learned
why type checking the arguments, (e.g. (begin (f (assert x boolean?))
...)) ; the remainder of the begin is aware that x is a boolean)
2016-10-21 14:24:27 -04:00
WarGrey Gyoudmon Ju
efecd24e9d Improvements on typed/images/logos.rkt and typed/images/icons.rkt (#443) 2016-10-17 17:51:33 -04:00
Vincent St-Amour
4773283f8f Extend type of vector->list.
Closes #436.
2016-10-08 18:33:39 -05:00
Vincent St-Amour
2fc83b2868 Add missing source locations.
Closes #428.
2016-09-28 13:27:12 -05:00
Alex Knauth
bbb62da731 fix type of non-empty-string? (#427)
fixes #426
2016-09-12 09:17:57 -04:00
WarGrey Gyoudmon Ju
e706928a77 Improve type annotation of (get-backing-scale) (#424) 2016-09-08 16:23:40 -04:00
Sam Tobin-Hochstadt
07911cd613 Fix type of get-value in Slider%.
Reported by Tim Brown.
2016-09-07 08:53:03 -04:00
WarGrey Gyoudmon Ju
abdc0e8ebc Add support for db/base and db/sqlite3 (#419) 2016-09-01 12:04:36 -04:00
Alex Knauth
dfd61642b6 unsafe-require/typed #:opaque doesn't warn about opaque structs passed as Any (#418) 2016-08-31 11:37:05 -04:00
Matthew Flatt
6b10a5480d accomodate a revised expansion of mandatory keyword arguments 2016-08-07 15:58:40 -06:00
Matthew Flatt
9a9c7d3d91 work with macros that use syntax-local-lift-values-expression
Using `syntax-local-lift-values-expression` creates a lifted
`define-values` form with multiple binding variables.
2016-08-07 15:57:40 -06:00
Vincent St-Amour
c256e47e27 Have literal-related optimizations see through ann. 2016-08-04 13:05:27 -05:00
Vincent St-Amour
3b488c1f13 Update test for new syntax-parse behavior.
Sees something twice that it used to see once.
2016-08-04 12:54:11 -05:00
Sam Tobin-Hochstadt
66da5eef00 Traverse #%expression when looking for annotations.
Bug found by @mflatt's change to `syntax-parameterize`.
2016-08-01 10:43:49 -04:00
Matthew Flatt
43aa1023c1 adjust unit expansion patterns to be more flexible
Like e707b64db1, but for units.

Also, adjust the `class` change to avoid duplicating patterns
and make it slightly more flexible.
2016-07-31 08:54:05 -06:00