Check for structure binding and raise good error if it is not there.

Closes PR 13588.

original commit: 87facb736fab1a79f064381433256f8b8a525688
This commit is contained in:
Eric Dobson 2013-03-24 18:34:46 -07:00
parent 2393bd43a3
commit 44c905cf88
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,5 @@
#;
(exn-pred #rx"identifier bound to a structure type")
#lang typed/racket/base
(require/typed racket/async-channel
[#:struct (async-channel +) ()])

View File

@ -628,6 +628,10 @@ This file defines two sorts of primitives. All of them are provided into any mod
[extra-maker (and (attribute input-maker.extra)
(not (bound-identifier=? #'make-name #'nm))
#'maker-name)])
(define (extract-struct-info* id)
(syntax-parse id #:context stx
[(~var id (static struct-info? "identifier bound to a structure type"))
(extract-struct-info (syntax-local-value #'parent))]))
(quasisyntax/loc stx
(begin
(require (only-in lib type-des (nm orig-struct-info)))
@ -652,7 +656,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
#,(if (syntax-e #'parent)
(let-values (((parent-type-des parent-maker parent-pred
parent-sel parent-mut grand-parent)
(apply values (extract-struct-info (syntax-local-value #'parent)))))
(apply values (extract-struct-info* #'parent))))
#`(list (quote-syntax type-des)
(quote-syntax real-maker)
(quote-syntax pred)