`typed-racket-test/main` is now the file to run for almost everything.
`typed-racket-test/run` continues to exist so that DrDr preserves the
timing history.
Integration tests now print a progress meter, which should fix the
Travis timeouts.
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.
* Add `normalise-inputs` to special function env.
* Treat eta-expansion specially. Now
`(lambda (x ...) (f x ...))`
will typecheck like `f` but with a type restricted to
the size of `x ...`.
Currently, this special case only works for non-polymorphic
functions.
New strategy for compiling the (-> Any Boolean) type to a contract.
When possible, uses `struct-predicate-procedure?` instead of
wrapping in `(-> any-wrap/c boolean?)`.
Makes exceptions for untyped chaperones/impersonators over struct predicates;
those are always wrapped with `(-> any-wrap/c boolean?)`.
This change also affects (require/typed ... [#:struct ...]), but not #:opaque
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.
Previously, most of it was actually deterministic enumeration, which meant
repeating the same tests over and over again. We still want to run those,
if only to catch regressions, so now we run both enumeration and truly
random tests, separately.
This does mean that the set of tests being run for a given seed is not the
same as it used to, so old seeds won't give the same results as before.
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.
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
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
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
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
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.
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
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
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.
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.
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.
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.
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 ...)`.