X-Git-Url: http://git.lukelau.me/?p=scheme.git;a=blobdiff_plain;f=ast.scm;fp=ast.scm;h=342fe453a4d9276c36237e43e1a7069b5ec75670;hp=b3f21bd07d6d07ba2b64017cff0a365cbf77abd4;hb=e4dc23d659849c88cec8c7e57d0d463f9493850e;hpb=9fd836fa6cbc686d277684101319f835d55fc5b3 diff --git a/ast.scm b/ast.scm index b3f21bd..342fe45 100644 --- a/ast.scm +++ b/ast.scm @@ -99,10 +99,17 @@ [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))]) + ; 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))