Commit Graph

489 Commits

Author SHA1 Message Date
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
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
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
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
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
Matthew Flatt
e707b64db1 adjust class expansion patterns to be more flexible
Accomodate a potential changes to `syntax-parameterize`
and the way it's use by `class`, where the changes
mostly introduce some `#%expression` wrappers.
2016-07-30 21:39:12 -06:00
Asumu Takikawa
164b22de59 Add and document row-inst form, Row syntax
Before this, row instantiation was done with an ad-hoc
and undocumented syntax. Adding a new form works better
because rows should not be parsed as types.
2016-07-21 18:29:30 -04:00
Asumu Takikawa
10eb2542c6 Add syntax for poly structs in require/typed
Currently only works in unsafe requires. In other cases
it will emit an error instead.

Also bump version
2016-07-21 12:00:08 -04:00
Asumu Takikawa
98d0657141 Fix contracts for structs with the same name (PR 15330) (#410)
Fix contracts for structs with the same name

Closes PR 15330
2016-07-21 11:14:05 -04:00
Andrew Kent
0d577b78ce fix silly subtype cache bug 2016-07-20 09:28:20 -04:00
Sam Tobin-Hochstadt
5cc02a7592 Typed Racket history for 6.6. 2016-07-18 10:21:49 -04:00
Sam Tobin-Hochstadt
d1df2881ea Don't try to name casted values in the contract.
Relevant to Racket bug 15323.
2016-07-18 10:21:49 -04:00
Andrew Kent
a5c4ad2f77 have overlap use a current-seen list 2016-07-13 15:21:17 -04:00
WarGrey Gyoudmon Ju
8aa12e48df Add filesystem related functions (#397) 2016-07-12 08:33:59 -04:00
Ben Greenman
2409457930 type for #:limit-prefix? formatting option 2016-07-10 20:42:57 -04:00
Sam Tobin-Hochstadt
3d80322d27 Merge pull request #388 from AlexKnauth/allow-opaque
add a version of any-wrap/c that displays a warning on opaque structs
2016-07-09 20:17:16 -04:00
Sam Tobin-Hochstadt
c3a1202df1 Don't set current-inspector in Typed Racket.
There's not a good way to do this dynamically, and the initial
approach breaks programs.

Reverts part of 191ec136b6.

Relevant to #385.
2016-07-09 20:08:20 -04:00
AlexKnauth
8a3400eeee set include-extra-requires? in require/opaque-type 2016-07-09 15:50:15 -04:00
AlexKnauth
50aab9806f warning instead of error on opaque structs passed to #:opaque predicates
This fixes a math library error discussed here:
https://github.com/racket/typed-racket/pull/385#issuecomment-231354377
2016-07-08 23:04:31 -04:00
WarGrey Gyoudmon Ju
5175f9d873 add or improve lots of base definitions (#372) 2016-07-08 20:41:54 -04:00
Sam Tobin-Hochstadt
88f896c121 Support environment variable procedures. 2016-07-08 16:27:16 -04:00
Sam Tobin-Hochstadt
b1818723dc Allow environment-variables? values as flat in any-wrap/c.
Fixes the `envy` package by @lexi-lambda.
2016-07-08 14:50:00 -04:00
Sam Tobin-Hochstadt
977b9e16a2 Allow cpointer predicates as struct predicates.
Fixes the math library failure here:
  http://drdr.racket-lang.org/35897/racket/share/pkgs/math-lib/math/private/bigfloat/bigfloat-hurwitz-zeta.rkt

Relies on racket/racket#1368.

Relevant to #385.
2016-07-08 11:02:57 -04:00
Alex Knauth
191ec136b6 fix any-wrap/c unsoundness on opaque structures (#385) 2016-07-07 20:58:26 -04:00
Alex Knauth
9f3cf01d26 don't throw internal errors for unreachable cast exprs (#386)
This fills the corresponding entries in the cast table with a Dead-Code
type so that when the contract-generation pass calls the contract-def
thunk, it finds that in the table.
2016-07-07 16:51:08 -04:00
Alex Knauth
e3f56c8a25 check for free-vars in types of casted-exprs (#384) 2016-07-07 14:45:07 -04:00
Andrew Kent
39d6a6047a better rec type intersection 2016-07-07 12:53:31 -04:00
Alex Knauth
a1f8908a29 call compute-constraints instead of sc->constraints in get-max-contract-kind (#382)
* call compute-constraints instead of sc->constraints in get-max-contract-kind

* test cast on an intersection type involving Rec

* remove memory limit on sandboxed-unsafe-ops test
2016-07-07 12:16:15 -04:00
Alex Knauth
76cb6ae53d implement sc->constraints for recursive-sc (#381) 2016-07-03 22:47:52 -04:00
Alex Knauth
d7670250d4 add (and/c vector? any-wrap/c) -like contracts
for VectorTop, HashTableTop, etc. going from typed to untyped
2016-06-29 17:04:11 -04:00
Alex Knauth
9bda1bfcbc fix the error message in issue #375 2016-06-29 17:04:06 -04:00
Sam Tobin-Hochstadt
79ab11a079 listof not listof/c. 2016-06-23 12:09:08 -04:00