summaryrefslogtreecommitdiff
path: root/language
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2021-03-07 08:43:31 +0100
committerRicardo Wurmus <rekado@elephly.net>2021-03-07 08:43:31 +0100
commit3005e128df284e2eaa2b1558c33c8636102ef0ba (patch)
treec9d81493eccd63a1654894ef09ede9ba71e5f254 /language
parent2bd13a69e5f54b4c8b95ec25766b1d846f77a19e (diff)
spec: primitive-type-checker: Recurse into lists.
* language/aws/spec.scm (primitive-type-checker): Use the primitive-type-checker recursively for list values that are (wrappers around) primitive types.
Diffstat (limited to 'language')
-rw-r--r--language/aws/spec.scm25
1 files changed, 18 insertions, 7 deletions
diff --git a/language/aws/spec.scm b/language/aws/spec.scm
index 3a6614b..a4c56ee 100644
--- a/language/aws/spec.scm
+++ b/language/aws/spec.scm
@@ -70,13 +70,24 @@ if this is not a primitive data type."
("list"
(let ((member-spec (assoc-ref exp "member")))
(if member-spec
- `(lambda (value)
- (let ((shape ',(string->symbol (assoc-ref member-spec "shape"))))
- (and (list? value)
- (every (lambda (item)
- (and=> (aws-name item)
- (cut eq? <> shape)))
- value))))
+ (let ((shape-name (string->symbol (assoc-ref member-spec "shape"))))
+ `(lambda (value)
+ (let ((shape ',shape-name))
+ (and (list? value)
+ ;; Use the primitive type checker here as well
+ ;; in case the member spec is a wrapper around
+ ;; a primitive value.
+ (every ,(let ((target-spec (assoc-ref %shape-specs shape-name)))
+ (if (and=> target-spec primitive?)
+ ;; Apply the primitive type check
+ ;; directly. This allows us to
+ ;; avoid unnecessary wrapping.
+ (primitive-type-checker target-spec)
+ ;; Otherwise make sure the value has the correct type
+ '(lambda (item)
+ (and=> (aws-name item)
+ (cut eq? <> shape)))))
+ value)))))
'list?)))
("map"
`(lambda (value)