Skip to content

Instantly share code, notes, and snippets.

@pnwamk
Created January 11, 2015 00:21
Show Gist options
  • Save pnwamk/018926c002ac2ec170e9 to your computer and use it in GitHub Desktop.
Save pnwamk/018926c002ac2ec170e9 to your computer and use it in GitHub Desktop.
let aliasing internal error test
#lang typed/racket/base
(module foo-home typed/racket/base
;(provide foo) ;; comment this line to see THE ERROR
(provide in-foo)
(require (for-syntax racket/base))
;; -- taken from 'math/private/Foo/typed-array-struct.rkt'
(struct: (A) foo ([shape : (Vectorof Index)]
[size : Index]
[strict? : (Boxof Boolean)]
[strict! : (-> Void)]
[unsafe-proc : ((Vectorof Index) -> A)]))
;; -- end 'math/private/array/typed-array-struct.rkt'
(define-sequence-syntax in-foo
(λ () #'in-foo)
(λ (stx)
(syntax-case stx ()
[[(x) (_ arr-expr)]
(syntax/loc stx
[(x)
(:do-in
([(ds size dims js proc)
(plet: (A) ([arr : (foo A) arr-expr])
(cond [(foo? arr)
(define ds (foo-shape arr))
(define dims (vector-length ds))
(define size (foo-size arr))
(define proc ((inst foo-unsafe-proc A) arr))
(define: js : (Vectorof Index) (make-vector dims 0))
(values ds size dims js proc)]
[else
(raise-argument-error 'in-foo "foo" arr)]))])
(void)
([j 0])
#true
([(x) (proc js)])
#true
#true
[0])])]
[[_ clause] (raise-syntax-error 'in-Foo "expected (in-foo <foo>)" #'clause #'clause)]))))
(require (submod "." foo-home))
;(: for-foo (-> (foo Any) Void))
(define (for-foo arr)
(for ([sample (in-foo arr)]) (void)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment