Commit Graph

159 Commits

Author SHA1 Message Date
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