diff options
author | Eduardo Julian | 2019-04-17 19:27:17 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-04-17 19:27:17 -0400 |
commit | c501d1357241df39573893d9b6dbcf44a22f4554 (patch) | |
tree | 1ad59e5611318390ad322aa83c3129b154d94530 /stdlib/source/lux/tool | |
parent | d544e863afbb5b52ba0299724846497fdaf308d1 (diff) |
Pattern-matching can now handle universally quantified sums.
Diffstat (limited to 'stdlib/source/lux/tool')
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/analysis/case.lux | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/case.lux b/stdlib/source/lux/tool/compiler/phase/analysis/case.lux index 9d7c9ea7f..dff106eb7 100644 --- a/stdlib/source/lux/tool/compiler/phase/analysis/case.lux +++ b/stdlib/source/lux/tool/compiler/phase/analysis/case.lux @@ -90,9 +90,9 @@ (#.ExQ _) (do ///.monad - [[ex-id exT] (//type.with-env - check.existential)] - (recur envs (maybe.assume (type.apply (list exT) caseT)))) + [[var-id varT] (//type.with-env + check.var)] + (recur envs (maybe.assume (type.apply (list varT) caseT)))) (#.Apply inputT funcT) (.case funcT @@ -215,7 +215,7 @@ thenA]))) _ - (/.throw cannot-match-with-pattern [inputT pattern]) + (/.throw cannot-match-with-pattern [inputT' pattern]) ))) [cursor (#.Record record)] @@ -260,8 +260,17 @@ _ (/.throw sum-has-no-case [idx inputT]))) + (#.UnivQ _) + (do ///.monad + [[ex-id exT] (//type.with-env + check.existential)] + (analyse-pattern num-tags + (maybe.assume (type.apply (list exT) inputT')) + pattern + next)) + _ - (/.throw cannot-match-with-pattern [inputT pattern])))) + (/.throw cannot-match-with-pattern [inputT' pattern])))) (^ [cursor (#.Form (list& [_ (#.Tag tag)] values))]) (/.with-cursor cursor |