Commit Graph

528 Commits

Author SHA1 Message Date
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
Asumu Takikawa
b5dc5585be Fix part of GH issue #208
For private `define-values` in classes with multiple variables, don't
eagerly throw type errors in the synthesis step. Instead, wait
until the later checking step when the environment will be correctly
set up.

When the initial synthesis typecheck fails, yield type Any for
the environment. If the typecheck should really fail, this is ok. If
not, then the user can add a type annotation.

A better long-term strategy is to change the handling of environments
so that the type environment gets refined as definitions are checked.
This way all annotations that the user writes are factored into the
initial environment and unannotated variables will have their types
synthesized.
2015-10-20 14:06:32 -04:00
Vincent St-Amour
bbe3521530 Update history.
Please merge to 6.3.
2015-10-20 11:20:46 -05:00
Vincent St-Amour
d2a7fb31bc Improve internal error checking. 2015-10-19 16:23:26 -05:00
Vincent St-Amour
22bfce117b Add missing bits to type and ignore tables for make-object-related code. 2015-10-19 16:23:26 -05:00
Vincent St-Amour
36a40b8334 Ignore code that results from the expansion of keyword function call sites
...that also involve contracts.

That code was previously not marked as lifted by the contract system, and
thus was not ignored by TR. But TR was not giving it a type, which made the
optimizer unhappy, now that it looks at the types of everything.
2015-10-19 16:23:26 -05:00
Vincent St-Amour
4aed44370d Ignore more code that has no types. 2015-10-19 16:23:26 -05:00
Vincent St-Amour
6245807b7c Log uses of float vectors.
For OC to recommend using flvectors instead.
2015-10-19 16:23:26 -05:00
Vincent St-Amour
6ccb0939f8 Have optimizer skip more code that is not typechecked. 2015-10-19 16:23:26 -05:00
Asumu Takikawa
3149b0a305 Fix send on a receiver with recursive type
Thanks to Matthias for finding the bug
2015-10-19 16:27:11 -04:00
Asumu Takikawa
638618ae40 Fix unsafe-require/typed for kw functions 2015-10-16 15:52:21 -04:00
Asumu Takikawa
30ecfef309 Fix type of system-type
Closes GH issue #210
2015-10-10 14:59:49 -04:00
Asumu Takikawa
435e733d66 Forgot to add fixes into last commit 2015-09-30 18:16:51 -04:00
Asumu Takikawa
e8820503e7 Fix source location tracking for top-level forms
This had broken due to trampoline-based refactoring
2015-09-30 17:03:22 -04:00
Asumu Takikawa
2cbadeaccc Bump version for typed/racket/unsafe addition
Also add history annotations to docs
2015-09-30 15:37:02 -04:00
Asumu Takikawa
eb90cd4e8c Add a typed/racket/unsafe library.
Comes with `unsafe-require/typed` and `unsafe-provide`.
These operations do not generate contracts but are not
exported by default by Typed Racket.
2015-09-29 18:48:08 -04:00
Georges Dupéron
7f8e91c571 Used new #:context variant (list symbol stx) for the error messages for , as per samth's suggestion. 2015-09-29 18:32:01 -04:00
Georges Dupéron
09d60e003b Simplified bad syntax error reporting for let (changes c8f02eb by samth) 2015-09-29 18:32:01 -04:00
Asumu Takikawa
eb93a2b571 Improve typechecking for equality
Closes GH issue #164
2015-09-22 22:57:18 -04:00
Daniel Feltey
c6743b4423 Don't expose require-typed-signature 2015-09-13 04:09:48 -05:00
Daniel Feltey
cbb76b987c Fix tc/letrec-values contract and document require-typed-signature 2015-09-12 13:45:33 -05:00
Vincent St-Amour
f89d91d864 Add timing for contract generation. 2015-09-11 13:39:03 -05:00
Vincent St-Amour
5ed30d7fcf Fix contract build. 2015-09-11 13:12:49 -05:00
Daniel Feltey
2e0cc095c7 Initial support for typed units in typed racket.
Most unit forms are supported, including most of the "infer" forms that
infer imports/exports/linkages from the current context.

Notably, none of the structural linking forms for units are supported, and
`define-unit-binding` is also currently unsupported.
2015-09-10 16:32:11 -05:00
Asumu Takikawa
26c4a199fb Fix accidentally added redundant requires
See last commit
2015-09-09 17:54:09 -04:00
Asumu Takikawa
3d6418b8be Refactor provide handling to reduce code 2015-09-09 12:50:32 -04:00
Asumu Takikawa
2b2e87010a Update version dependency on base
Depends on the rename transformer change
2015-09-09 11:59:43 -04:00
Alexis King
4bf3479776 Add types for writeln and println 2015-09-08 15:58:07 -04:00
Asumu Takikawa
241f04bcdb Fix typed provide uses in some modules
When identifiers provided by typed modules were used in
certain submodules of the form (module* n #f ...) or were
used by modules implemented in a language defined by TR,
the wrong redirection was used in the expansion.

The reason was because TR's identifier redirection decided
whether it was in a typed or untyped context at module visit
time, but that's too early in the cases above.

(because TR's #%module-begin may not have begun expanding yet)

The fix uses a rename-transformer that delays the decision
to use the typed or untyped identifier until expansion time.

Closes GH issue #163 and #181

Closes PR 15118
2015-09-08 15:53:34 -04:00
Asumu Takikawa
552f509102 Refactor the renamer module
Moves `get-alternate` since its only user is the require-contract
module. In addition, it appears that one of the cases in the
conditional in its body is unnecessary. This likely means that
the extra machinery for typed-renamers are not needed at all.

Also adds a test for `require/typed` of a typed module
2015-09-08 13:31:02 -04:00
Vincent St-Amour
fd3941c062 Remove dependency on unstable/contract. 2015-09-07 21:38:22 -05:00
Sam Tobin-Hochstadt
c8f02eb93f Improve error message for (let).
Closes #193.
2015-09-07 17:31:46 -04:00
Vincent St-Amour
a25a07987e Update type of pretty-format. 2015-09-07 15:35:14 -05:00
Brian Lachance
77334808a8 Allow AnyValues as a return type in user code
Closes PR 14217
2015-09-07 13:26:34 -05:00
Vincent St-Amour
9ab862c668 Remove now unused bound-names parameter. 2015-09-07 13:26:07 -05:00
Vincent St-Amour
602223e74a Prevent open SC terms.
Closes PR 15144.
2015-09-07 13:24:16 -05:00
Alexis King
c48abf6dff Fix typo in generated contract for Nonpositive-Integer 2015-08-29 16:41:10 -07:00
Asumu Takikawa
f5f84c7625 Fix for*/fold and for*/lists
Only parse and use the type annotations if they are present on
all fold variables. This matches the default for other forms in TR.
Also, this will usually result in a "insufficient type information"
message which is more helpful than if TR chose some default type.

Closes PR 15138
Closes PR 14893
2015-08-25 11:44:24 -04:00
Spencer Florence
9fb79b4e18 more missing srclocs 2015-08-22 08:42:14 -04:00
Spencer Florence
1d2da49dfb fixed src loc propigation for n-ary*->binary 2015-08-22 08:42:14 -04:00
Asumu Takikawa
20f3badc98 Enable prefab support correctly for define-struct
I had forgotten to adjust the define-struct macro to work
like the struct macro for the #:prefab keyword, which made
TR think prefabs were ordinary structs.

Closes GH issue #188
2015-08-21 16:38:04 -04:00
Asumu Takikawa
51cd8db3d6 Add types for a few missing syntax functions
Also fix some existing types
2015-08-20 17:08:47 -04:00
Spencer Florence
c8ebec62e8 fixed unbox-let optimization srcloc propigation 2015-08-20 15:20:51 -05:00
AlexKnauth
30cdfd16cc print more Error types as Error types 2015-08-17 17:48:00 -04:00
Asumu Takikawa
d4a9052f52 Fix outdated comment for redirect-contract 2015-08-17 13:12:25 -04:00
AlexKnauth
0ea39a1177 clean up unused definition 2015-08-16 00:00:58 -05:00
AlexKnauth
0037a0277f allow values with define-new-subtype types as functions 2015-08-15 19:00:35 -05:00
AlexKnauth
efb877dbfb fix inference with define-new-subtype 2015-08-15 14:36:45 -05:00
AlexKnauth
f8cc9e8dcd fix issue #169 2015-08-14 21:42:20 -05:00
Asumu Takikawa
dfdf86e527 Add identifier-binding-symbol to TR base-env 2015-08-14 21:25:54 -04:00
Asumu Takikawa
2e97280335 Eliminate the eval hack for top-level structs
This eliminates a hack used to make the `struct` form
work at the TR top-level. The trampolining top-level
typechecker makes this unnecessary.
2015-08-14 21:25:54 -04:00
Asumu Takikawa
d85a267c42 Declare require/typed internal identifier first
Uses the `define-syntaxes` trick to declare the identifier
so that its binding symbol doesn't change later.
2015-08-14 21:25:54 -04:00
Asumu Takikawa
e031d6c47e Typecheck the top-level using trampolining macros
Instead of local-expanding the entire top-level forms at
once, wrap expressions in a top-level begin in trampolining
macro forms. This allows the typechecker to trampoline back
to the evaluator, which is necessary to declare/register
declarations made in a top-level begin.

The point of this change is to eliminate top-level hacks
and faciliate various macros that need to communicate using
multiple top-level forms.
2015-08-14 21:25:54 -04:00
Asumu Takikawa
84bd502d46 Refactor TR top-interaction
Use a macro to abstract out the implementation of most
of the top-level TR commands.
2015-08-14 21:25:54 -04:00
Asumu Takikawa
94ce4b203e Use tc-expr for top-interaction functions instead
This restricts operations like `:print-type` to only
work on expressions. This seems like a reasonable
restriction and simplifies the implementation.
2015-08-14 21:25:54 -04:00
Vincent St-Amour
e997f02095 Rewrite compound pair operation optimization.
Previous version replaced calls to, e.g., `cadr` with calls to `cdr`
then `car`, called the typechecker to populate the type table, then
optimized the exploded operations. The call to the typechecker failed
on open terms, limiting the applicability of the optimization, and was
just generally brittle.

The new version instead explodes operations, then optimizes them inside
out for as long as the argument's type guarantees it's safe. This works
on open terms, and should be more robust.
2015-08-14 17:28:47 -05:00
Asumu Takikawa
509f1aa20c Update type for copy-directory/files 2015-08-14 01:02:54 -04:00
Vincent St-Amour
aae17a0bc0 in-pairs -> in-dict 2015-08-13 10:41:15 -05:00
Vincent St-Amour
b6362e7eb3 unstable/sequence -> racket/sequence
And move to TR one of the functions that didn't make it.
2015-08-13 10:41:15 -05:00
Asumu Takikawa
4f050888e2 Export let*-values from TR correctly
Closes PR 14997
2015-08-12 12:16:05 -04:00
Asumu Takikawa
29144c7932 Fix handling of let rhs that don't return
In the case that a let rhs doesn't return and therefore the
bodies of the let are unreachable, the bodies need to be marked
as ignored for the optimizer.

In addition, don't attempt unboxed let optimization at all
if the return type is Nothing since it probably means some
body expressions have no type.

Closes GH issue #165
2015-08-11 12:07:27 -04:00
Asumu Takikawa
6512b52b1d Fix polymorphic recursion check for type aliases
The old check was broken for cases with type constructors
with more than one type argument and was also too conservative
in some cases (e.g., when one cycle refers to another cycle of
 aliases in a non-recursive manner).

The new check is still conservative, but it allows more types
than before.

Closes GH issue #157
2015-08-07 19:05:13 -04:00
Vincent St-Amour
b9268e99db Move syntax-length to TR. 2015-08-05 13:13:51 -05:00
Vincent St-Amour
11a8a3e1d9 unstable/syntax -> syntax/location 2015-08-05 13:13:51 -05:00
AlexKnauth
0c1d58a07b handle define-new-subtype in earlier phase 2015-07-30 23:24:17 -04:00
Brian Lachance
a97489cc80 Fix attempt at handling internal errors when binding AnyValues results
This is the correct change for how attempting to bind AnyValues results
caused internal type-checking errors. The root cause was get-type/infer
violating its own contract by using the default return value from
tc-error/expr

This (partially) reverts 5e0e8ed713.
2015-07-30 16:21:07 -04:00
AlexKnauth
a58c2e317f add define-new-subtype
inspired by haskell newtypes
http://www.mail-archive.com/racket-users@googlegroups.com/msg27118.html
https://www.haskell.org/tutorial/moretypes.html
2015-07-30 01:39:06 -04:00
Sam Tobin-Hochstadt
a0b7123d4c Handle for-meta in TR requires. 2015-07-29 14:28:24 -07:00
Brian Lachance
5e0e8ed713 Fix missing match cases when trying to bind AnyValues typed "results"
tc-toplevel has fixes for define's, tc-let-unit has fixes for let's
2015-07-29 11:44:29 -04:00
Brian Lachance
1e5bc30b95 Prevent -let-internal name from leaking to users
Because -let-internal wasn't rename-out'd, users would see its name in
syntax error messages. Adding #:context forces the error messages to be
phrased in terms of the given form.
2015-07-29 11:07:54 -04:00
Asumu Takikawa
91279f46c7 Add types for recent functions moved from unstable 2015-07-28 14:49:26 -04:00
Asumu Takikawa
2819a62b30 Add types for new syntax operations 2015-07-27 17:15:54 -04:00
Daniel Feltey
44a93b7e43 Merge print-syntax? and show-input? parameters into just the print-syntax? parameter 2015-07-26 19:30:39 -05:00
Alex Knauth
f1da9c22c1 Merge pull request #160 from btlachance/colon-checksyntax-arrows
Cancel marks for 'disappeared-use ids in colon macros
2015-07-23 16:51:41 -04:00
Brian Lachance
045bf05381 Cancel marks for 'disappeared-use ids in colon macros
Fixes check-syntax arrows for the id and optional second :
2015-07-23 14:59:52 -04:00
Vincent St-Amour
f92bddd21b Move rest of unstable/logging from typed-racket-lib to unstable-lib. 2015-07-23 11:48:39 -05:00
Vincent St-Amour
a097521f38 Move part of of unstable/logging to racket/logging. 2015-07-23 11:48:39 -05:00
Vincent St-Amour
6c9593bd73 Move unstable/match to the unstable-lib package.
See additional comments in the corresponding commit to the `unstable` repo.
2015-07-23 11:48:39 -05:00
Sam Tobin-Hochstadt
577b5225cd Fix construction of promise contracts; broken in 5cd5f772. 2015-07-22 16:29:39 -04:00
Sam Tobin-Hochstadt
5cd5f772d6 Don't allow promises created with delay/name as (Promise T).
Since these promises re-evaluate their bodies every time they
are forced, allowing them makes `force` not idempotent and not
safe to treat as a path.

This change is slightly backwards-incompatible, since programs
that previously passed `delay/name` promises across the typed
boundary will now fail at runtime. The alternative is also
incompatible: stop treating `force` as a path. Since `delay/name`
is quite obscure, this approach seems like the safer choice.
2015-07-22 14:22:34 -04:00
Vincent St-Amour
19c42b28a7 Move filter-multiple to utils file. 2015-07-20 16:17:39 -05:00
Vincent St-Amour
28c9bdf37b Fix base version dependency. 2015-07-20 16:17:39 -05:00
Vincent St-Amour
f35b5a9182 check-duplicate -> check-duplicates 2015-07-20 16:17:39 -05:00
Vincent St-Amour
9abb1927ee Replace uses of unstable/hash with racket/hash. 2015-07-20 16:17:39 -05:00
Vincent St-Amour
72fb041211 Replace uses of unstable/function and /list with the equivalent core libs. 2015-07-20 16:17:39 -05:00
Sam Tobin-Hochstadt
fca96dcdc1 Quote typecheck-fail-internal properly.
Caught by existing unit tests.
2015-07-20 15:34:49 -04:00
Matthew Flatt
1842aaa2bd fixes for some tests
The `identifier-binding` function is now senstive to the "macro
introduction" scope that's on an indentifier provided to a currently
expanding macro. Unit tests for TR need to use
`syntax-local-intorduce` to remove it, in the same way that `tc-setup`
already does.

Also, recognize a class expansion when it's wrapped with
`#%expression`, since `class` now expands that way sometimes.
2015-07-16 08:40:35 -06:00
Matthew Flatt
8c006da763 remove syntax-local-make-delta-introducer 2015-07-16 08:40:34 -06:00
Matthew Flatt
2d095c4112 adapt to letrec-syntaxes+values removal and quote-syntax extension
The `quote-syntax` form now suports a `#:local` option, which is
used for type annotations to preserve binding context.

Since `letrec-syntaxes+values` is now removed by `local-expand`,
some patterns must be adjusted, including the pattern used
for type annotations.
2015-07-16 08:40:34 -06:00
Matthew Flatt
2f00de99d0 declare empty namespace for submodules
Using the enclosing module's context for the `#f` part of the
`(module* _ #f ....)` would generally enable a compact encoding of
bindings for the purposes of `module->namespace`. Disabling
`module->namespace` for the generated submodules seems more reliable,
and it seems unlikely that anyone will miss the extra debugging
capability (which is all that is lost for these submodules whose
content is, I think, unspecified).
2015-07-16 08:40:34 -06:00
AlexKnauth
aec5fad4be make append preserve non-emptyness of first argument
see https://github.com/racket/scribble/pull/8#discussion_r33423152
2015-06-28 12:07:42 -04:00
Sam Tobin-Hochstadt
9a2b74dc33 Generate trivial constraints for missing type variables.
If the type variable isn't mentioned anywhere, then just
pick `Any` as its substitution.

Fixes #152.
2015-06-23 16:08:23 -04:00
Vincent St-Amour
6bef6e6ca8 Make type of abs and magnitude more precise.
Fixes a failing test.
2015-06-16 12:00:07 -05:00
Eric Dobson
0498f548c1 Fix the type of abs on negative zeros. 2015-06-16 10:43:01 -05:00
Asumu Takikawa
0892e23892 Resolve expected type in tc-lambda-unit
Closes #144
2015-06-10 12:23:39 -04:00
Asumu Takikawa
bc3443b393 Change Module-Path type to accommodate submodules
Closes #84
2015-06-10 12:21:51 -04:00
Sam Tobin-Hochstadt
91e3a1b5f0 Make sure that user-specified clauses come before default clauses in type-case.
Avoids nasty hash ordering bugs.
2015-06-02 17:32:33 -04:00
Asumu Takikawa
b63514a2c3 Allow more flexible keywords in ->* types
Keyword argument types in ->* are now allowed intermixed with
positional arguments instead of at the end.

Closes #145
2015-06-02 01:05:05 -04:00
Eric Dobson
8014db0f7d Make infer unfold Mu before spliting on Unions. 2015-05-19 20:44:15 -07:00
Eric Dobson
d4eaa47b27 Make subtype use hash of hashs.
This has a 1% improvement on new-metrics.rkt by my measurements.
2015-05-19 20:37:41 -07:00
AlexKnauth
e075523e5e change type of partition 2015-05-19 16:29:49 -04:00
Alexis King
a096857a88 Disable the #{} reader macro if a dispatch macro already exists on #\{ 2015-05-14 14:35:30 -07:00
AlexKnauth
b11e48fa93 don't raise error for require/typed in module-begin context 2015-05-14 12:13:14 -04:00
Alex Knauth
c6b1f8fdc0 syntax error for require/typed in untyped code 2015-05-14 12:13:14 -04:00
Asumu Takikawa
92d1dd1c5e Add sealing contracts for row polymorphic types
This enables contract generation in the negative
direction (untyped->typed) for row polymorphic types
(basically mixin types).

Depends on `class-seal` and `class-unseal` in
the racket/class library.
2015-05-13 20:52:32 -04:00
Marc Burns
609d6189e9 Improve typecheck for private field initializers
This patch addresses two issues with `typed/racket/class`:

1. For multiple private fields declared with `define-values`, type
information does not propagate from the values produced by the
initialization expression to the declared fields. This breaks soundness
of private fields: A field can be annotated with a type that does not
contain the field's initial value.

This was resolved by keeping a table of temporary bindings introduced in
the expansion of the initializer along with their types. The field
setter's type is then checked against that of the corresponding
temporary.

2. The class body typechecker assumes that the `expr` of
a `define-values` clause will expand to a bare `(values vs ...)`.

This was resolved by generalizing the template for matching an expanded
`define-values` initializer and extracting the type information from the
`expr` instead of each element in `(vs ...)`.
2015-05-12 18:42:05 -04:00
Asumu Takikawa
5751a2e1cf Refactor get-field checking to avoid bad names 2015-05-12 15:08:53 -04:00
Eric Dobson
90061c2b96 Add filters for trivial cases in arithemetic procedures. 2015-05-02 08:26:50 -07:00
Eric Dobson
22342d6a35 Simplify flsqrt type. 2015-05-02 08:26:50 -07:00
Eric Dobson
fc4e216fc2 Simplify flexp type. 2015-05-02 08:26:50 -07:00
Eric Dobson
142b52918c Fix types for flmin and flmax.
flmin and flmax only take two arguments.
2015-05-02 08:26:50 -07:00
Eric Dobson
848b69b73d Simplify flonum comparison types. 2015-05-02 08:26:50 -07:00
Eric Dobson
d288b14244 Expand type of fl/. 2015-05-02 08:26:50 -07:00
Eric Dobson
c50b6291e2 Cleanup fl* type. 2015-05-02 08:26:50 -07:00
Eric Dobson
811cd211e9 Tighten fl+ and fl- types. 2015-05-02 08:26:49 -07:00
Eric Dobson
c3c134780e Cleanup fx shifts. 2015-05-02 08:26:49 -07:00
Eric Dobson
3c978d82cb Tighten fxior and fxxor. 2015-05-02 08:26:49 -07:00
Eric Dobson
424658f6ab Tighten fxmin and fxmax.
Replace Zero case with all NonNegative or NonPositive values.
2015-05-02 08:26:49 -07:00
Eric Dobson
93b538b694 Cleanup types of fixnum comparisons.
Unify Zero and One cases, and remove extraneous ones.
2015-05-02 08:26:49 -07:00
Eric Dobson
114b9376f1 Tighten type of fxabs. 2015-05-02 08:26:49 -07:00
Eric Dobson
ad09e941a8 Tighten type of fxquotient 2015-05-02 08:26:49 -07:00
Eric Dobson
c923663e55 Tighten type of fx*
Make multiplication by Zero return Zero and by One return the other arg.
2015-05-02 08:26:49 -07:00
Eric Dobson
6bc24fdf83 Fixup type of fx-
fx- is not commutative.
Output is always a fixnum.
2015-05-02 08:26:48 -07:00
Eric Dobson
b6a53b8916 Cleanup types of fx+
Fix case for two Bytes which should be Index not PosIndex.
2015-05-02 08:26:48 -07:00
Eric Dobson
86d5845bc4 Replace exclude-zero with commutative-equality/strict-filter.
Make it more obvious what the generated type is.
Also removes NaN from the specific type for flonums because that was
incorrect.
2015-05-02 08:26:48 -07:00
Eric Dobson
69e613c831 Simplify types for nan? and infinite? 2015-05-02 08:26:48 -07:00
Eric Dobson
e91cdad6b0 Tighten types on sgn. 2015-05-02 08:26:48 -07:00
Eric Dobson
ddd503a203 Fix type on integer-sqrt/remainder.
It doesn't return exact integers when given inexact input.
2015-05-02 08:26:48 -07:00
Eric Dobson
eeef1a7c55 Simplify types of integer-sqrt. 2015-05-02 08:26:40 -07:00
Eric Dobson
70fdc3dd13 Make flonum and ext-flonum types use the same definitions.
This avoids problems where one could be changed to fix a bug and the
other would be missed.
2015-04-28 20:27:44 -07:00
Vincent St-Amour
257d4ec9a7 Fix use of values in type of integer-sqrt/remainder.
Closes PR 15034.
2015-04-28 17:49:53 -04:00
Asumu Takikawa
a80f55946d Adjust error messages for : annotation form
Print better error messages for expression like
(: 2 Zero). Also fix and improve error messages for
multiple/missing types.

Closes PR 15044
2015-04-21 16:07:13 -04:00
Andrew Kent
cbbf5536d8 no objects for mutated private class fields
tidy up ->acc
2015-04-08 17:53:00 -04:00
Asumu Takikawa
7bf4314af4 Simplify Name type representation
Avoids contract errors by using a simpler representation
and sticking with it throughout.
2015-04-08 11:23:48 -04:00
Asumu Takikawa
d22bf8cc11 Fix type-name-env contracts and uses 2015-04-08 11:23:48 -04:00
Eric Dobson
f0c48cfb87 Make abs return its argument on -NonNegReal. 2015-04-07 09:50:33 -07:00
Eric Dobson
a522768b7e Make tc-subst restrict returned types based on argument types. 2015-04-07 09:50:32 -07:00
Eric Dobson
7a29e8e369 Simplify cases in comparisons with -Zero or -RealZero 2015-04-07 08:23:32 -07:00
Eric Dobson
1ad0a2b181 Remove extra cases in comparisons for -One 2015-04-07 08:23:32 -07:00
Eric Dobson
b77bd862a0 Stop trying to represent rest objects because they are currently broken.
Closes #83.
2015-04-07 08:13:38 -07:00
Eric Dobson
b8921ff4df Fix contract on subst-type.
subst-type now can be called with Values? and such.
2015-04-06 09:58:06 -07:00
Eric Dobson
a33b27a3c9 Remove many cases of = that are unnecessary. 2015-04-05 19:10:51 -07:00
Eric Dobson
7b762933c6 Simplify the type of zero?. 2015-04-05 19:07:12 -07:00
Eric Dobson
be225976d3 Make subtype work with restricted filters.
Closes PR 15025.
2015-04-05 19:07:12 -07:00
Eric Dobson
db3826c474 Add comments for changes to substitution. 2015-04-05 18:01:11 -07:00
Sam Tobin-Hochstadt
6a262c19fa Add prefab structs to HISTORY. 2015-04-03 21:33:39 -04:00
Sam Tobin-Hochstadt
0793021514 History update for Typed Racket. 2015-04-03 18:45:38 -04:00
Sam Tobin-Hochstadt
583ca906b3 Significantly reduce dependencies.
In conjunction with a small change to syntax/parse, this means
that `typed/racket/base` no longer depends on `racket/set`,
`racket/contract/base`, or `racket/generic`.

Timings on my machine go from ~200ms for `#lang typed/racket/base`
as the whole file, to ~100ms. For comparison, `racket/base` is 30ms
and `#lang racket` is 150ms. `#lang typed/racket` is ~200ms with
this change.

Changes include:
 - not using `in-syntax`
 - switching to `syntax/parse/pre`
 - avoiding `template` from `syntax/parse`
2015-04-03 12:50:55 -04:00
Asumu Takikawa
7b5478e0bc Make Place-Channel <: (Evtof Any) 2015-04-02 11:00:25 -04:00
Asumu Takikawa
c70910aaa0 Fix type restriction in values->tc-results
Previously the restriction didn't account for traversing
the object type with the given path. This also relies on
the previous commit that adds subtyping on filters.

(because this change seems to introduce filters which
 only differ by an unrolling of a recursive type, but
 the old subtyping only worked for identical types)
2015-04-02 10:58:45 -04:00
Asumu Takikawa
8acc86bb9b Add subtyping for types inside filters
This makes a type like

  (-> Any Boolean : #:+ Integer)

a subtype of a type like

  (-> Any Boolean : #:+ Number)

For not filters, the direction is reversed.
2015-04-01 18:54:00 -04:00
Eric Dobson
889d96ca78 Strengthen infinity checks in comparison operations.
This adds checks for infinity when comparing against reals and accounts
for NaNs.
2015-03-30 09:25:48 -07:00
Eric Dobson
3889036b12 Simplify types for positive? and negative?. 2015-03-30 09:12:51 -07:00
Eric Dobson
5de22c80f7 Make values->tc-results restrict to the original type of the object. 2015-03-30 09:12:25 -07:00
Eric Dobson
e5ea1f4bb6 Make zero? sound with regards to NaN. 2015-03-28 14:08:20 -07:00
Sam Tobin-Hochstadt
718bc82b5d Avoid providing def-redirect. 2015-03-26 12:23:48 -04:00
Alexis King
b54d8dc04a Strengthen the types for member, memv, memq, and memf
Fixes #61.
2015-03-25 16:44:42 -07:00
Vincent St-Amour
b3bdb40ab7 Optimize pair operations, even in the absence of syntactic pair types. 2015-03-24 16:47:06 -04:00
Alexis King
2a4ce892ae Merge branch 'integral-to-inexact' 2015-03-20 19:43:04 -07:00
Alexis King
aab2d9efcf Include more specific types for integers converted to floats 2015-03-19 18:54:11 -07:00
Sam Tobin-Hochstadt
ee7bed777b Add dependency on 6.2.0.2.
This is definitely needed for the new `begin-encourage-inline`
submodule, but also needed for various other changes (such as
`dynamic-object/c`).
2015-03-19 21:45:15 -04:00
Sam Tobin-Hochstadt
0dce19e4bf Reduce more dependencies.
Use `syntax/parse/pre` (checked with @rmculpepper).
Use new `begin-encourage-inline` submodule.
Remove use of `match` in TR runtime-loaded code.
2015-03-19 21:41:58 -04:00
Sam Tobin-Hochstadt
4709536653 Split prims.rkt to reduce dependencies.
There are several new files: one for structure prims, one for
annotation-related prims, one for contract related ones. The prims-contract
file uses trickery with submodules to avoid a direct dependency
on `racket/contract`.

Additionally, the rewritten versions of `for/set` et al now use
a submodule to avoid a direct dependency on `racket/set`.
2015-03-18 18:47:49 -04:00
Sam Tobin-Hochstadt
333a8b9bd7 Remove long lines, and inline vector-copy to remove dependency. 2015-03-18 18:23:56 -04:00
Asumu Takikawa
7a09bac1e3 Handle more cases for opt-arg function contracts
Allow more cases that are allowed for ordinary function
contracts and explicitly error instead of internal errors
for other cases.

Closes Github Issue #50
2015-03-17 15:52:21 -04:00
TwoPoint7182818
911036c2a6 Make order-of-magnitude more specific
(order-of-magnitude n) is only negative if n < 1. Hence it is non-negative for all positive integers.
2015-03-15 20:48:46 -04:00
Asumu Takikawa
8106d318f1 Fix first-order check for TR's opaque object/c
Closes PR 15003
2015-03-13 16:52:34 -04:00
Asumu Takikawa
197cdeac9b Fix contract, remove comment signature 2015-03-12 01:35:54 -04:00
Asumu Takikawa
d19bed0e8b Fix inaccurate data definition comment 2015-03-10 15:18:03 -04:00
Asumu Takikawa
8e6710438f Support prefabs for unsafe-struct-ref 2015-03-10 15:18:02 -04:00
Asumu Takikawa
5d708ab53f Add typechecking for prefab structs
Adds a new Prefab type constructor along with support for
the use of `struct` with the #:prefab keyword.
2015-03-10 15:14:51 -04:00
Asumu Takikawa
50f2271917 Fix minor contract violation in REPL messages 2015-03-09 15:59:02 -04:00
Asumu Takikawa
c00cc17e07 Add cond-contracts to name-env functions
This helped for debugging, especially since some of
the comments were inaccurate. Removed contract comments
that aren't more specific than the code contracts.
2015-03-09 15:59:02 -04:00
Asumu Takikawa
fb0c96e7f0 Forgot to add this change to the previous commit
(put requires in the right phase)
2015-03-09 15:57:22 -04:00
Asumu Takikawa
96e741dc1b Add srcloc instead of a quoted syntax for casts 2015-03-06 16:09:31 -05:00
Sam Tobin-Hochstadt
a3e25231a6 Look up unrenamed versions of type aliases as well.
Fixes bug reported by Alexander Knauth.
2015-03-06 12:13:40 -05:00
Sam Tobin-Hochstadt
7a67243d68 Fix contract provide fixup to handle contracts at the beginning. 2015-03-06 09:41:29 -05:00
Matthew Flatt
011649a654 move contract submodules to start of enclosing module
Putting the contract submodules early enough allows them to be used
for `module*` submodules.

Repairs a problem reported by Alexander:
 http://lists.racket-lang.org/users/archive/2015-March/066164.html
2015-03-06 09:41:29 -05:00
Alexis King
c79b61a751 Adjust named-let to use the return type annotation whenever possible
Fixes #43
2015-03-04 15:17:35 -08:00
Asumu Takikawa
33543ce054 Use absent in some row poly class contracts
When exporting row polymorphic functions from TR, just
use absent clauses to ensure that TR won't accidentally
try to add pre-existing fields/methods. No sealing is
needed because the typechecker enforces parameteric use
of the class.
2015-03-04 16:26:35 -05:00
Asumu Takikawa
8d0c352dcc Add a custom object contract for use in TR
This corresponds to the more strict object contracts
from the OOPSLA paper. Also use `object/c-opaque` in
TR contract generation
2015-03-04 16:26:35 -05:00
Asumu Takikawa
e2fd3b6653 Enable opaque class contracts in TR 2015-03-04 13:28:06 -05:00
Asumu Takikawa
e80f17cbad Adjust contract generation for some Instance types 2015-03-04 13:27:31 -05:00
Andrew Kent
ea942c2110 fixed base/value overlap bug 2015-03-03 23:20:15 -05:00
Alexis King
3f67cfea7c Use contract-neg-party to accurately handle contracted applications
Fixes #38
2015-03-03 16:15:09 -08:00
Andrew Kent
766bd83a98 removed subtle latent bug in tc-let-unit
there was a values mismatch bug hiding in here that hadn't ever (to my knowledge) been triggered -- perhaps this code is dead?
2015-03-01 12:27:51 -05:00
Asumu Takikawa
165a2afa5b Fix augment/inner contract generation 2015-02-28 14:02:57 -05:00
Matthew Flatt
4116acc2d0 define-runtime-module-path-index for reference to a contract submodule
Cooperate with `raco exe`.
2015-02-27 13:39:46 -07:00
Asumu Takikawa
ec15f58542 Basic support for contract gen for PolyRow types
Currently only supports the typed export side. The other
way needs contract features that haven't been merged yet.
2015-02-27 15:19:30 -05:00
Asumu Takikawa
6a855f664c Reorganize type->contract for polymorphic methods 2015-02-27 13:37:07 -05:00
Asumu Takikawa
d0a8b8c25b Fix prims for quote-syntax -> quote change 2015-02-27 00:17:02 -05:00
Andrew Kent
5d84201789 fixed proposition parsing 2015-02-26 13:46:42 -05:00
Matthew Flatt
4622a4cc32 use quote instead of quote-syntax for annotations in macro expansion
The choice of identifier is arbitrary, but avoiding `quote-syntax`
may be more forward-comptiable as the macro system changes.
2015-02-25 21:15:23 -07:00
Matthew Flatt
1469306a8e use free-id=? instead of bound-id=? for letrec analysis
With the current macro expander, either should work, but
`free-id=?` is arguably the right choice for determining
that two identifiers refer to the same binding.
2015-02-25 21:15:18 -07:00
Asumu Takikawa
78fc0f19e7 Improve types for private field accessors
Enables better occurrence typing for private fields
2015-02-23 15:38:28 -05:00
Asumu Takikawa
5b237018ef Add a #:var argument to ->acc
Allows a name reference for Path objects to be specified
for ->acc function types.
2015-02-23 15:38:28 -05:00
Asumu Takikawa
fed9ac40eb Adjust the recursive type alias registration pass
Instead of registering aliases before we find out if they are
recursive or not, register them after that information is found.
That avoids spurious aliases that end up in the type name
environment without the need for a `remove-type-name` operation.
2015-02-23 15:38:28 -05:00
Alexis King
425c584a30 Handles expansion of internal forms inside splicing-syntax-parameterize
Fixes PR 14973

Closes #24.
2015-02-21 15:40:23 -05:00
Asumu Takikawa
39446d64d5 Fix internal error format string in init-envs 2015-02-17 18:29:12 -05:00
Asumu Takikawa
5180e601db Adjust the fix in 619d6945c3
For unions of multiple type aliases the new placeholder
would cause union collapsing incorrectly. Put an uninterned
symbol in the placeholder types to avoid this.
2015-02-17 14:00:07 -05:00
Alexis King
619d6945c3 Prevent type alias placeholders from collapsing in unions with symbols
Fixes #26
2015-02-16 13:22:35 -05:00
Asumu Takikawa
d0a7c911df Improve plambda-handling in check-class-unit
Simplify the property copying code for method processing.
2015-02-16 02:42:57 -05:00
Asumu Takikawa
d77044f902 Minor refactoring to use #:when in a match clause 2015-02-13 00:12:14 -05:00
Asumu Takikawa
52cc284d87 Better error msg for structs with the same name
Thanks to Max for the suggestion
2015-02-13 00:10:19 -05:00
Asumu Takikawa
83dc3884aa Fix accessor type for with-tr-contracts test 2015-02-12 23:44:19 -05:00
Asumu Takikawa
31d6c04608 Use Univ instead of (make-Univ) 2015-02-12 16:31:18 -05:00
Asumu Takikawa
62c86d5ddd Added occurrence typing for private fields.
This also tracks mutation of private fields to ensure that only
non-mutated field types are allowed to be refined.
2015-02-12 16:31:18 -05:00
Asumu Takikawa
177d1a7f68 Adjust type of dynamic-require (returns 1 value)
The implementation (and now docs) of dynamic-require
specifies that it can only return a single value, even
when the required binding is syntax.
2015-02-12 14:25:44 -05:00
Asumu Takikawa
7ae1247539 Add missing types for Ref. 18.2.3 functions 2015-02-11 14:27:52 -05:00
Asumu Takikawa
917ecaae9b Fix type for current-library-collection-paths
Closes PR 14975
2015-02-11 14:27:40 -05:00
Sam Tobin-Hochstadt
13614ae5c2 Always use rename-out in generated provides.
Since rename-transformers can generate free-id=? names, we could
end up providing two things with the same name.

Fixes PR 14972.
2015-02-09 16:40:39 -05:00
Sam Tobin-Hochstadt
bafc7d93e7 Raise proper errors when there are too many contract constraints.
Fixes PR 14890.

This could potentially be relaxed if needed, but this addresses
the immediate issue.
2015-02-09 16:37:32 -05:00
Sam Tobin-Hochstadt
ae0717d970 Move generated contracted provides to a submodule.
This allows the main TR module not to explicitly
depend on the contract library. Each exported name
can be redirected to either the original name (for a
typed client) or to another macro (for an untyped
client) which expands to a `local-require` for the
relevant submodule (named `#%contract-defs`).

Thanks to Matthew for the initial idea and an
implementation in plai-typed that this is based on.
2015-02-08 20:37:04 -05:00
Asumu Takikawa
6c09d52b2e Generalize method handling in TR
Previously, TR only recognized a subset of the syntax that
the class macro accepts for method definitions (and errored
unhelpfully on other cases). Though that subset was sufficient
for most methods, macros will sometimes produce unusual forms.
2015-02-08 18:29:37 -05:00
Vincent St-Amour
787df49140 Make type of division more lenient.
Thanks to John Clements for the report.
2015-02-04 14:06:54 -05:00
Asumu Takikawa
8402ee1635 Add FSemaphores to Typed Racket 2015-02-02 11:23:09 -05:00
Asumu Takikawa
e85cc55f6f Add types for call-with-semaphore 2015-02-02 02:54:01 -05:00
Alexis King
032a11fdae Add support for use-dir? param of in-directory
Closes #21.
2015-01-31 09:34:01 -05:00
Alexis King
7122d93de8 Make Path a subtype of Module-Path
Closes #20.
2015-01-31 09:33:50 -05:00
Alexis King
9bad7f0128 Improve the type for directory-list 2015-01-29 09:55:06 -05:00
Asumu Takikawa
1cbdad12f6 Remove uses of srfi/1 in Typed Racket 2015-01-28 13:31:56 -05:00
Vincent St-Amour
ef35d21a31 Refine type of current-inexact-milliseconds.
Thanks to Alex Knauth for the report.
2015-01-27 20:30:28 -05:00
Alex Knauth
d93b387150 more useful types for hasheqv and hasheq too
Closes #16.
2015-01-24 12:37:12 -05:00
Alex Knauth
19455584ab more useful type for hash
still only up to 8 arguments
2015-01-24 12:36:16 -05:00
Asumu Takikawa
066e4356b4 Support type alias definitions in class bodies 2015-01-22 14:22:11 -05:00
Asumu Takikawa
a45fd96224 Remove unneeded unit imports in check-class-unit 2015-01-21 16:19:20 -05:00
Asumu Takikawa
5c090ba686 Fix new error messages for class/object types
Closes PR 14942
2015-01-21 13:55:19 -05:00
Asumu Takikawa
8e63b14f4c Fix contract for contracted TR tests 2015-01-21 13:55:11 -05:00
Asumu Takikawa
4ab7ba2578 Improve check-below errors for classes/objects
Also fix a type-checker bug that the tests for the
error messages uncovered.
2015-01-20 19:58:25 -05:00
Alexis King
b9e600dc1a Add contract generation support for Async-Channelof 2015-01-19 21:11:09 -05:00
Asumu Takikawa
455bc7664b Fix type dictionary entries for overriden methods
Add typed Racket Esquire as a test case
2015-01-19 16:12:31 -05:00
Asumu Takikawa
874f426e9c Remove unnecessary requires in extra-env-lang.
Avoids phase 0 dependencies on TR internals.
2015-01-19 13:41:29 -05:00
Sam Tobin-Hochstadt
5ba9633e78 Improve hash-table overlap.
Thanks to Alex Knauth for the code and Jordan Johnson for the test case.
2015-01-19 09:48:50 -05:00
Asumu Takikawa
769cd04b37 Add cond-contract requires to fix contracted tests 2015-01-18 14:20:50 -05:00
David Van Horn
88afb40f60 Parens 2015-01-17 12:54:31 -05:00
Andrew Kent
7633d6d1b8 let/ec swapped out in update 2015-01-17 14:20:30 +05:30
Sam Tobin-Hochstadt
9a39c3e793 Add for/set and for*/set to Typed Racket. 2015-01-16 09:43:37 -05:00
Andrew Kent
e7d61bd982 fixed struct field updates 2015-01-14 15:32:34 +05:30
Asumu Takikawa
e922807837 Fix contract for tc/send 2015-01-14 00:23:28 -05:00
Asumu Takikawa
2c0d4b8aec Undo local-require change from 7afeada73d
Recent changes to contract generation have made this
`local-require` unnecessary. Using `require` is preferable
since `local-require` can interact poorly with submodules.
2015-01-14 00:23:27 -05:00
Andrew Kent
8c5c032520 Merge pull request #10 from andmkent/master
path-type now allows normal internal errors
2015-01-14 06:09:25 +05:30
Asumu Takikawa
ded837ce10 Fix tc/send to accept keyword argument methods
Closes PR 14910
2015-01-12 18:36:35 -05:00
Andrew Kent
fd4f05e64b path-type sep file 2015-01-10 15:11:10 -05:00
Andrew Kent
f3104f383e path-type allow non-subtype struct acc
proper path-type mismatch error
2015-01-10 15:10:05 -05:00
Asumu Takikawa
9bf90a7734 Add more type abbreviations 2015-01-09 13:36:36 -05:00
Asumu Takikawa
de926372fa Loosen contracts for with-tr-contracts unit test 2015-01-09 11:19:57 -05:00
Andrew Kent
3ed6b464e7 overlap tests for Seq and Evt, minor overlap fix 2015-01-06 15:01:16 -05:00
Andrew Kent
16db5ecc78 dont let-alias type vars, better overlap & restrict 2015-01-06 13:51:40 -05:00
Andrew Kent
dc2ce38aef Merge pull request #5 from andmkent/master
fixed mutation let-aliasing bug
2015-01-05 09:15:57 -05:00
Asumu Takikawa
8a663a5499 Remove unnecessary function argument 2015-01-04 20:33:46 -05:00
Asumu Takikawa
dbaebdd305 Propagate expected types better for private fields
Closes PR 14911
2015-01-04 19:39:14 -05:00
Andrew Kent
9d41048747 fixed mutation let-aliasing bug
let-aliasing initially forgot to check if a variable that might act as
an alias was ever mutated. fixed by disallowing a mutated variable to
act as an alias.
2015-01-03 23:03:45 -05:00
Vincent St-Amour
a943d85375 Preserve more source locations for function definitions. 2015-01-02 20:57:08 -05:00
Asumu Takikawa
791a16e54f Fix method definitions with lambda/case-lambda
Closes PR 14904
2015-01-01 01:59:37 -05:00
Asumu Takikawa
6059fb481b Check expected type before calling tc/funapp1
This compensates for a change in commit bb3f446186
that made the possible-domains function more permissive
(possibly returning results that are inconsistent with the
 expected type).

Closes PR 14889
2015-01-01 00:03:23 -05:00
Asumu Takikawa
643c20afdb Add missing contract generation error cases
Functions with dotted values or AnyValues in the return type
aren't yet supported for contract generation.

Related to PR 14894
2014-12-27 05:31:46 -05:00
Andrew Kent
e1b8eff1f9 initial let-aliasing addition 2014-12-22 12:35:30 -05:00
Andrew Kent
53d1d8a15d restrict structural recursion 2014-12-22 12:35:15 -05:00
Andrew Kent
683ebb1023 printer fix for paths 2014-12-22 12:34:48 -05:00
Andrew Kent
76effbb423 better Or implied-atomic? & unit tests 2014-12-13 22:13:31 -05:00
Vincent St-Amour
fe3a935d0c Add missing newline for :print-type.
Closes PR 14880.
2014-12-12 16:38:58 -05:00
Sam Tobin-Hochstadt
933e571125 Don't compare non-identifiers with free-id=?.
Closes PR 14877.
2014-12-10 17:53:46 -05:00
Sam Tobin-Hochstadt
44e3cdfb71 Remove extra directories. 2014-12-02 00:53:36 -05:00