projects
/
scheme.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Check for let pattern matches that they have only one sum
[scheme.git]
/
ast.scm
diff --git
a/ast.scm
b/ast.scm
index b3f21bd07d6d07ba2b64017cff0a365cbf77abd4..342fe453a4d9276c36237e43e1a7069b5ec75670 100644
(file)
--- a/
ast.scm
+++ b/
ast.scm
@@
-99,10
+99,17
@@
[type (data-tor-type data-layouts sum-name)]
[type (data-tor-type data-layouts sum-name)]
- [sum (assoc sum-name (cdr (assoc type data-layouts)))]
+ [sums (cdr (assoc type data-layouts))]
+ [sum (assoc sum-name sums)]
[expected-number (length (cdr sum))])
[expected-number (length (cdr sum))])
+ ; assert that we only do a let pattern match on an ADT with exactly one sum
+ (when (not (= 1 (length sums)))
+ (error #f (format "Cannot pattern match a ~a in a let since it has ~a possible constructors"
+ type
+ (length sums))))
+
; assert that there is the correct number of bindings
(when (not (= (length products)
expected-number))
; assert that there is the correct number of bindings
(when (not (= (length products)
expected-number))