Commit Graph

582 Commits

Author SHA1 Message Date
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
Sam Tobin-Hochstadt
8bcfc71fa8 Avoid overlap with sequences of the wrong arity.
Fixes #371.
2016-06-23 12:00:53 -04:00
Asumu Takikawa
b8225e1100 Factor out type alias error helper
Mainly for single point of control.
2016-06-22 18:53:04 -04:00
Asumu Takikawa
c29eb20efc Decide to lift common types based on popularity
Instead of looking at the size of the type, check to see
how many times each type is referenced in other types.
Only lift a type out as a definition if it reaches a
threshold (currently set to 5 refs).

This reduces the zo size of typed/private/framework-types
by roughly 1MB (more than half).

Also move more of the env code generation into the
init-envs.rkt file itself.
2016-06-22 18:53:04 -04:00
Asumu Takikawa
11439eb653 Move struct table code gen to init-envs.rkt
This keeps all the code generation in one place.
2016-06-22 18:50:41 -04:00
Asumu Takikawa
ee02c26020 Fix bug in init-envs (need to generate Rows too)
Also simplified Class case a bit
2016-06-22 17:47:46 -04:00
Asumu Takikawa
ca26d22d1c Fix optimizer fix
Fixed spurious syntax quoting and a test
2016-06-22 00:24:31 -04:00
Sam Tobin-Hochstadt
34ff91b3ca Avoid misoptimizing vector-set! of immutable vectors. 2016-06-21 18:05:38 -04:00
Asumu Takikawa
3b5ea8dc39 Improve how memoization in init-envs is done
Instead of storing a parameter with a box, use a
module-level variable with a hash table and a separate
queue. This separates memoization and the generation
of definitions, which is cleaner.
2016-06-21 16:37:17 -04:00
Asumu Takikawa
c5ec933bb8 Add more predefined types 2016-06-21 16:37:17 -04:00
Asumu Takikawa
0730c48000 Remove pconvert dependency 2016-06-21 16:37:17 -04:00
Asumu Takikawa
bd0c71c122 Try abbreviating optional argument function types 2016-06-21 16:37:17 -04:00
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
Asumu Takikawa
d23e05f2c3 Escape "~" in tc-error/fields arguments
Fixes issue #314
2016-03-02 04:43:34 -05:00
Georges Dupéron
350a8bb74e Changed how arguments and other pieces of information are printed, to follow the error message conventions, as suggested by samth in PR #250 .
* PR #250: https://github.com/racket/typed-racket/pull/250
* Error message conventions: http://docs.racket-lang.org/reference/exns.html?q=raise-arg#%28part._err-msg-conventions%29
2016-03-01 15:19:09 -06:00
Stephen Chang
5d8949654e add more hash seq ids to base special env
sync with commit 3e29101e48
2016-02-24 15:28:38 -05:00
Asumu Takikawa
72927e2248 Add the rest of Racket's exn hierarchy 2016-02-21 12:20:40 -05:00
Asumu Takikawa
a90f6c46eb Add exn:break:hang-up and exn:break:terminate 2016-02-21 02:48:45 -05:00
Stephen Chang
e1b9c06d5c remove old in-hash- private ids 2016-02-06 12:49:50 -05:00
Stephen Chang
c19fac7fd5 add ids from in-hash- expansion to special-env
- fixes test failures due to 048c4b4a73
- add in-hash- tests
2016-02-05 18:26:03 -05:00
Sam Tobin-Hochstadt
5f35f447b5 TR History 2016-02-01 14:43:16 -05:00
Vincent St-Amour
32d0a97058 Add contract profiling instrumentation to combinators defined by TR. 2016-01-27 16:01:07 -06:00
Stephen Chang
2e7a045012 bump version to support extra hash-iterate ops 2016-01-27 10:32:55 -05:00
Stephen Chang
3a245a27e0 fix type of hash-iterate-key+value 2016-01-26 17:06:33 -05:00
Stephen Chang
c35716d461 add hash-iterate-pair and hash-iterate-key+value
closes #299
2016-01-26 10:21:05 -05:00
Sam Tobin-Hochstadt
9ba130976c Fix hash iteration types for HashTableTop. 2016-01-23 11:56:51 -05:00
Asumu Takikawa
0308a229ed Ensure define-typed-struct/exec has a Procedure
Fixes issue #293
2016-01-22 13:43:03 -05:00
Sam Tobin-Hochstadt
8ca2af0f8c Fix simple-result-> when passed a keyword-accepting procedure. 2016-01-17 17:55:46 -05:00
Asumu Takikawa
bad5a35291 Fix type of file-position
Closes issue #297
2016-01-17 16:38:21 -05:00
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