Seemingly valid cast gives confusing error message
Open
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 575
- Forks
- 106
- Avg merge
- 2h 1m
- Merged PRs (30d)
- 2
Description
What version of Racket are you using?
v7.0
What program did you run?
#lang typed/racket/base
(cast add1 (Number → Number))
What should have happened?
Cast succeeds.
If you got an error message, please include it here.
; c:\Program Files\Racket\share\pkgs\typed-racket-lib\typed-racket\base-env\prims-contract.rkt:292:15: Type Checker: Error in macro expansion -- Type (case-> (-> Zero One) (-> One Positive-Byte) (-> Byte Positive-Index) (-> Index Positive-Fixnum) (-> Negative-Fixnum Nonpositive-Fixnum) (-> Nonpositive-Fixnum Fixnum) (-> Nonnegative-Integer Positive-Integer) (-> Negative-Integer Nonpositive-Integer) (-> Integer Integer) (-> Nonnegative-Exact-Rational Positive-Exact-Rational) (-> Exact-Rational Exact-Rational) (-> Nonnegative-Flonum Positive-Flonum) (-> Flonum Flonum) (-> Nonnegative-Single-Flonum Positive-Single-Flonum) (-> Single-Flonum Single-Flonum) (-> Nonnegative-Inexact-Real Positive-Inexact-Real) (-> Inexact-Real Inexact-Real) (-> Nonnegative-Real Positive-Real) (-> Real Real) (-> Float-Complex Float-Complex) (-> Single-Flonum-Complex Single-Flonum-Complex) (-> Inexact-Complex Inexact-Complex) (-> Number Number)) could not be converted to a contract: function type has two cases of arity 1
; in: (U (case-> (-> Zero One) (-> One Positive-Byte) (-> Byte Positive-Index) (-> Index Positive-Fixnum) (-> Negative-Fixnum Nonpositive-Fixnum) (-> Nonpositive-Fixnum Fixnum) (-> Nonnegative-Integer Positive-Integer) (-> Negative-Integer Nonpositive-Integer...
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the failing cast example and inspect typed-racket/base-env/prims-contract.rkt around line 292, where the reported macro-expansion error originates. Determine why the shown function type cannot be converted to a contract, then verify that the example succeeds without the confusing error.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100