Comments (4)
After some more investigation, this typechecks as well.
(: f (Number [#:y Boolean] [#:z Nothing] -> Number))
(define (f x #:y [y #f] #:z [z 'this-can-be-anything])
(if y "y is truthy" x))
I'm not sure why giving a parameter the Nothing
type makes the typechecker do this. I'll keep looking into it, but I'm not completely sure where I should be looking.
from typed-racket.
Also, this produces an internal error with no useful information.
(: g (Nothing -> Any))
(define (g [x 'x] [y 'y]) 'g)
Internal Typechecker Error: no type for (if y11 y9 (quote y)) at: #f line #f col #f
while typechecking:
here
originally:
here
EDIT: Looks like this is actually a bug in the optimizer, since turning off optimizations stops it from erroring, though it feels indicative of a larger problem.
from typed-racket.
I believe I’ve independently encountered this bug. The function f1
compiles, but loses its types (the types of 'bool' and 'syms' are reported as Any).
But if I add a dummy keyword argument, as in f2
, then everything typechecks fine: 'bool' is reported as a Boolean and 'syms' is (Listof Symbol).
(: f1 (() (Boolean) #:rest Symbol . ->* . Any))
(define (f1 [bool #t] . syms)
bool
syms)
(: f2 (() (Boolean #:x Integer) #:rest Symbol . ->* . Any))
(define (f2 [bool #t] #:x [x 42] . syms)
bool
syms)
from typed-racket.
@mbutterick I've filed a separate bug report for that case, #58, based on your information. It may turn out to be related, but I'm not sure, and I think it's quite possible that they're different.
from typed-racket.
Related Issues (20)
- for loop fails to infer subtype.
- Examples of unexpected behavior for integer refinements
- `AnyValues` in `let/cc` is unbound.
- The `Nothing` type causes the type checker not to check the type. HOT 2
- struct #:mutable field option
- any-wrap: avoid wrapping immutable structs with immutable fields HOT 3
- Strange lack of subtyping for `case->` HOT 1
- Constructors in `typed/web-server/http` not provided
- Weird Error Message from `require/typed`
- apply < doesn't accept a non-empty list
- `check-eq? (hasheq) (hasheq)` fails HOT 4
- TR unsound with keyword args HOT 2
- `struct`'s `#:methods` missing in Typed Racket HOT 3
- The new hash match pattern doesn't work in Typed Racket
- type mismatch when using `Float`s with `for/sum` HOT 1
- `require/typed/provide` not providing constructors
- `require/typed` yields "unused require" warnings
- TR fails to typecheck when using optional arg and inline type specs
- treelists not supported in Typed Racket
- Can't use #:property to seal a Typed Racket structs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typed-racket.