forked from alex-eg/sex
refuse _ in a pub var's type
Importers declare a pub var from its type alone, with nothing to solve a wildcard against, so (pub var n _ 42) reached them as extern _ n.
This commit is contained in:
@@ -138,6 +138,7 @@
|
||||
(reverse
|
||||
(fold
|
||||
(lambda (form acc)
|
||||
(check-written-out form)
|
||||
(fold (lambda (use acc) (check-type-use form use visible hidden acc))
|
||||
acc
|
||||
(append-map (lambda (type) (type-uses type #f))
|
||||
@@ -145,6 +146,20 @@
|
||||
(list)
|
||||
forms))))
|
||||
|
||||
;;; Importers declare a pub var from its type, not its initializer, so
|
||||
;;; there is nothing on their side to solve a `_' with
|
||||
(define (check-written-out form)
|
||||
(match form
|
||||
(('pub 'var . _)
|
||||
(match (strip-header-comments form 4)
|
||||
(('pub 'var name type . _)
|
||||
(when (let wildcard? ((t type))
|
||||
(or (eq? t '_) (and (pair? t) (any wildcard? t))))
|
||||
(sex-error form "a pub var's type is what importers declare it with; write it out"
|
||||
name)))
|
||||
(_ #f)))
|
||||
(_ #f)))
|
||||
|
||||
;;; USE is (name . behind-a-pointer?)
|
||||
(define (check-type-use form use visible hidden acc)
|
||||
(let* ((name (car use))
|
||||
|
||||
Reference in New Issue
Block a user