diff options
Diffstat (limited to 'stdlib/source/lux.lux')
-rw-r--r-- | stdlib/source/lux.lux | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 9e370f12b..b75b5bebe 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -5568,12 +5568,19 @@ (def: (multi-level-case$ g!_ [[init-pattern levels] body]) (-> Code [Multi-Level-Case Code] (List Code)) (let [inner-pattern-body (list@fold (function (_ [calculation pattern] success) - (` (case (~ calculation) - (~ pattern) - (~ success) - - (~ g!_) - #.None))) + (let [bind? (case pattern + [_ (#.Identifier _)] + #1 + + _ + #0)] + (` (case (~ calculation) + (~ pattern) + (~ success) + + (~+ (if bind? + (list) + (list g!_ (` #.None)))))))) (` (#.Some (~ body))) (: (List [Code Code]) (list@reverse levels)))] (list init-pattern inner-pattern-body))) @@ -5601,6 +5608,12 @@ (^ (list& [_meta (#Form levels)] body next-branches)) (do meta-monad [mlc (multi-level-case^ levels) + #let [initial-bind? (case mlc + [[_ (#.Identifier _)] _] + #1 + + _ + #0)] expected get-expected-type g!temp (gensym "temp")] (let [output (list g!temp @@ -5613,9 +5626,10 @@ ("lux check" (#.Apply (~ (type-to-code expected)) Maybe) (case (~ g!temp) (~+ (multi-level-case$ g!temp [mlc body])) - - (~ g!temp) - #.None)))))] + + (~+ (if initial-bind? + (list) + (list g!temp (` #.None)))))))))] (wrap output))) _ |