Given a tr.rkt
like:
#lang typed/racket/base
(require plot/typed)
(plot (function vector-ref) 0 1) ;nonsense, but just for error message
You get something like:
#lang racket | |
;; Let's write an untyped Racket module that works fine when `require`d | |
;; by untyped Racket. But also, let's try to use it from Typed Racket. | |
(provide foo | |
macro-foo) | |
;; A user may `require/type` this _function_, and it works fine. | |
(define (foo x) |
#lang typed/racket | |
(~a 1) | |
;; racket /tmp/tr.rkt | |
;; /tmp/tr.rkt:1:0: Type Checker: untyped identifier apply-contract imported from module <private/base.rkt> | |
;; in: #%module-begin | |
;; context...: | |
;; /Applications/Racket_v5.93/share/pkgs/typed-racket-lib/typed-racket/utils/tc-utils.rkt:98:12: for-loop | |
;; f18 | |
;; /Applications/Racket_v5.93/share/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:227:0: type-check |
#lang racket/base | |
(require syntax/parse | |
racket/match | |
racket/port | |
(only-in racket/list filter-map remove-duplicates) | |
rackjure/threading) | |
(provide -read | |
-read-syntax |
#lang typed/racket | |
(: foo (Real -> (Integer -> Float))) | |
(define (foo n) | |
(const n)) | |
; /tmp/tr.rkt:5:2: Type Checker: Polymorphic function `const' could not be applied to arguments: | |
; Argument 1: | |
; Expected: a | |
; Given: Real |
~/src/plt/racket$ make CPUS=1 | |
if [ "1" = "" ] ; \ | |
then make plain-in-place PKGS="main-distribution plt-services" ; \ | |
else make cpus-in-place PKGS="main-distribution plt-services" ; fi | |
make[1]: Entering directory `/home/greg/src/plt/racket' | |
make -j 1 plain-in-place JOB_OPTIONS="-j 1" PKGS="main-distribution plt-services" | |
make[2]: Entering directory `/home/greg/src/plt/racket' | |
make base | |
make[3]: Entering directory `/home/greg/src/plt/racket' | |
mkdir -p build/config |
#lang typed/racket/base | |
(require racket/flonum) | |
(module+ test | |
(require typed/rackunit) | |
(define (from upto) | |
(for/flvector ([i (in-range from upto)]) | |
0.0))) | |
; Type Checker: Error in macro expansion -- insufficient type information to typecheck. please add more type annotations | |
; in: ((require typed/rackunit) (define (from upto) (for/flvector ((i (in-range from upto))) 0.0))) |
Here's what I think is a variation of the same bug. | |
It uses `for:` (my original report involved using `for/flvector`). | |
--- | |
#lang typed/racket/base | |
(module m typed/racket/base | |
(: f (Nonnegative-Real -> Float)) |
### Keybase proof | |
I hereby claim: | |
* I am greghendershott on github. | |
* I am greghendershott (https://keybase.io/greghendershott) on keybase. | |
* I have a public key whose fingerprint is 2E96 43B5 C285 5815 6140 8A12 81A9 7656 9121 EC46 | |
To claim this, I am signing this object: |
Given these two files: | |
;; tr0.rkt | |
#lang typed/racket/base | |
(: f (Number -> Number)) | |
(define (f n) | |
n) | |
(provide f) | |
;; tr1.rkt |
Given a tr.rkt
like:
#lang typed/racket/base
(require plot/typed)
(plot (function vector-ref) 0 1) ;nonsense, but just for error message
You get something like: