typed-racket icon indicating copy to clipboard operation
typed-racket copied to clipboard

`identifier-binding-symbol: contract violation` after `raco demod`

Open benknoble opened this issue 10 months ago • 2 comments

I'm not 100% sure this is a TR bug, but here's the program:

#lang typed/racket

(define length #e1e4)
(define inner-loop (* 10 length))

(define u (cast (string->number (vector-ref (current-command-line-arguments) 0))
                Natural))
(define r (random (add1 length) (make-pseudo-random-generator)))
(: a (Vectorof Natural))
(define a (make-vector length))

(for ([i (in-range 0 length)])
  (for ([j : Natural (in-range 0 inner-loop)])
    (vector-set! a i (+ (vector-ref a i) (remainder j u))))
  (vector-set! a i (+ (vector-ref a i) r)))

(displayln (vector-ref a r))

The compiler steps:

raco make racket/typed-code.rkt
raco demod -o racket/typed-code.zo racket/typed-code.rkt
raco exe  -o racket/typed-code racket/typed-code.zo

And the output:

./racket/typed-code 43
identifier-binding-symbol: contract violation
  expected: identifier?
  given: #f
  context...:
   .../loops/boundmap.rkt:47:12: module-identifier-mapping-put!
   body of '#%mzc:typed-code

Making an exe the normal way (raco exe -o racket/typed-code{,.rkt}) and running as above works just fine. However, the exe is 69MiB instead of 47MiB.


System specs, in case they end up relevant:

OS: macOS 12.7.6 21H1320 x86_64 
Host: MacBookPro11,5 
Kernel: 21.6.0 
CPU: Intel i7-4870HQ (8) @ 2.50GHz 
GPU: Intel Iris Pro, AMD Radeon R9 M370X 
Memory: 8380MiB / 16384MiB 

I uploaded a hexdump of the .zo file created from xxd, if that helps.

benknoble avatar Dec 21 '24 20:12 benknoble