Specify names of missing fields for match on structs
This commit is contained in:
parent
22adc0253b
commit
56ea9f8b9a
|
@ -125,13 +125,32 @@
|
|||
=>
|
||||
(lambda (ps)
|
||||
(unless (= (length ps) (length acc))
|
||||
(raise-syntax-error
|
||||
'match
|
||||
(format "~a structure ~a: expected ~a but got ~a"
|
||||
"wrong number for fields for"
|
||||
(syntax->datum struct-name) (length acc)
|
||||
(length ps))
|
||||
stx pats))
|
||||
(when (< (length acc) (length ps))
|
||||
(raise-syntax-error
|
||||
'match
|
||||
(format "~a structure ~a: expected ~a but got ~a"
|
||||
"excess number of fields for"
|
||||
(syntax->datum struct-name) (length acc)
|
||||
(length ps))
|
||||
stx pats))
|
||||
(when (> (length acc) (length ps))
|
||||
(raise-syntax-error
|
||||
'match
|
||||
(format
|
||||
"~a structure ~a: expected ~a but got ~a; ~a ~a"
|
||||
"insufficient number of fields for"
|
||||
(syntax->datum struct-name) (length acc)
|
||||
(length ps)
|
||||
"missing fields"
|
||||
(list-tail
|
||||
(map (lambda (field)
|
||||
(string->symbol
|
||||
(substring (symbol->string (syntax->datum field))
|
||||
(add1 (string-length
|
||||
(symbol->string (syntax->datum struct-name)))))))
|
||||
acc)
|
||||
(length ps)))
|
||||
stx pats)))
|
||||
(map parse ps))]
|
||||
[else (raise-syntax-error
|
||||
'match
|
||||
|
|
Loading…
Reference in New Issue
Block a user