feat: support nested void matching
This commit is contained in:
parent
ac0c73a56a
commit
0ccfe60072
|
@ -2568,10 +2568,6 @@ impl<'a> CodeGenerator<'a> {
|
||||||
let (_, assign) = self.clause_pattern(pattern, subject_tipo, props, then);
|
let (_, assign) = self.clause_pattern(pattern, subject_tipo, props, then);
|
||||||
assign
|
assign
|
||||||
} else {
|
} else {
|
||||||
assert!(
|
|
||||||
!subject_tipo.is_void(),
|
|
||||||
"WHY ARE YOU PATTERN MATCHING ON A NESTED VOID???"
|
|
||||||
);
|
|
||||||
match pattern {
|
match pattern {
|
||||||
Pattern::Int { value, .. } => {
|
Pattern::Int { value, .. } => {
|
||||||
props.complex_clause = true;
|
props.complex_clause = true;
|
||||||
|
@ -2700,6 +2696,13 @@ impl<'a> CodeGenerator<'a> {
|
||||||
bool(),
|
bool(),
|
||||||
then,
|
then,
|
||||||
)
|
)
|
||||||
|
} else if subject_tipo.is_void() {
|
||||||
|
AirTree::clause_guard(
|
||||||
|
&props.original_subject_name,
|
||||||
|
AirTree::void(),
|
||||||
|
void(),
|
||||||
|
then,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
let (cond, assign) =
|
let (cond, assign) =
|
||||||
self.clause_pattern(pattern, subject_tipo, props, then);
|
self.clause_pattern(pattern, subject_tipo, props, then);
|
||||||
|
@ -4791,6 +4794,8 @@ impl<'a> CodeGenerator<'a> {
|
||||||
.force();
|
.force();
|
||||||
}
|
}
|
||||||
Some(term)
|
Some(term)
|
||||||
|
} else if tipo.is_void() {
|
||||||
|
Some(then.lambda("_").apply(Term::var(subject_name)))
|
||||||
} else {
|
} else {
|
||||||
let condition = if tipo.is_int() {
|
let condition = if tipo.is_int() {
|
||||||
Term::equals_integer()
|
Term::equals_integer()
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# This file was generated by Aiken
|
||||||
|
# You typically do not need to edit this file
|
||||||
|
|
||||||
|
requirements = []
|
||||||
|
packages = []
|
||||||
|
|
||||||
|
[etags]
|
|
@ -0,0 +1,4 @@
|
||||||
|
name = "thing/thing"
|
||||||
|
version = "0.0.0"
|
||||||
|
license = "Apache-2.0"
|
||||||
|
description = "Aiken contracts for project 'thing/thing'"
|
|
@ -0,0 +1,10 @@
|
||||||
|
pub fn wow(a: Void) -> Int {
|
||||||
|
when Some(a) is {
|
||||||
|
Some(Void) -> 42
|
||||||
|
None -> 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test wow_1() {
|
||||||
|
wow(Void) == 42
|
||||||
|
}
|
Loading…
Reference in New Issue