summaryrefslogtreecommitdiff
path: root/language
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2021-03-07 08:44:49 +0100
committerRicardo Wurmus <rekado@elephly.net>2021-03-07 08:44:49 +0100
commit54b59f500d4b45a3879b2a7bfc489fb53ba2b3c3 (patch)
tree8b3b559c9b09c828b5169a4b191478373c5ec9c4 /language
parent3005e128df284e2eaa2b1558c33c8636102ef0ba (diff)
spec: compile-shape: Prefer primitive type checkers for members.
* language/aws/spec.scm (compile-shape): Only check for the AWS shape type if the member value is a complex type and not merely a wrapper around a primitive type.
Diffstat (limited to 'language')
-rw-r--r--language/aws/spec.scm15
1 files changed, 12 insertions, 3 deletions
diff --git a/language/aws/spec.scm b/language/aws/spec.scm
index a4c56ee..c40367b 100644
--- a/language/aws/spec.scm
+++ b/language/aws/spec.scm
@@ -148,10 +148,19 @@ if this is not a primitive data type."
;; Type checks
,@(map (match-lambda
((name . spec)
- (let ((key-name (string->symbol name)))
+ (let* ((key-name (string->symbol name))
+ (target-shape (string->symbol (assoc-ref spec "shape")))
+ (target-spec (assoc-ref %shape-specs target-shape)))
`(unless (eq? ,key-name '__unspecified__)
- (ensure ,key-name
- ',(string->symbol (assoc-ref spec "shape")))))))
+ ,(if (and=> target-spec primitive?)
+ ;; Apply the primitive type
+ ;; check directly. This allows
+ ;; us to avoid unnecessary
+ ;; wrapping.
+ `(,(primitive-type-checker target-spec) ,key-name)
+ ;; Otherwise make sure the value has the correct type
+ `(ensure ,key-name
+ ',(string->symbol (assoc-ref spec "shape"))))))))
members)
(aws-structure
',scm-name