summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Schmidt <kaikaliischmidt@gmail.com>2024-09-30 20:36:10 -0700
committerKai Schmidt <kaikaliischmidt@gmail.com>2024-09-30 20:36:10 -0700
commitb40bb2e7d912a05de1a17dff98992ca84c314eb0 (patch)
treec2a5c2d441abe49ce2256d94089cd14a02d92fa2
parent35cdb57e64cc823935c3fcdc170e3cea60747371 (diff)
fix inversion of under experementalness
-rw-r--r--src/algorithm/invert.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/algorithm/invert.rs b/src/algorithm/invert.rs
index 3dfbdc2e..f4ae3c59 100644
--- a/src/algorithm/invert.rs
+++ b/src/algorithm/invert.rs
@@ -988,7 +988,7 @@ fn get_undered<'a>(
input: &'a [Instr],
comp: &mut Compiler,
) -> InversionResult<(UnderedFunctions, &'a [Instr])> {
- if let [Instr::PushFunc(g), Instr::PushFunc(f), Instr::Prim(Primitive::Under, span), input @ ..] =
+ let res = if let [Instr::PushFunc(g), Instr::PushFunc(f), Instr::Prim(Primitive::Under, span), input @ ..] =
input
{
Ok((
@@ -1004,16 +1004,19 @@ fn get_undered<'a>(
} else if input.len() < 3 {
generic()
} else {
- let res = (0..=input.len()).rev().find_map(|i| {
- comp.undered_funcs
- .get(&input[..i])
- .map(|u| (u.clone(), &input[i..]))
- });
- if res.is_some() && !comp.scope.experimental {
- return Err(InversionError::UnderExperimental);
- }
- res.ok_or(Generic)
+ (0..=input.len())
+ .rev()
+ .find_map(|i| {
+ comp.undered_funcs
+ .get(&input[..i])
+ .map(|u| (u.clone(), &input[i..]))
+ })
+ .ok_or(Generic)
+ };
+ if res.is_ok() && !comp.scope.experimental {
+ return Err(InversionError::UnderExperimental);
}
+ res
}
fn invert_under_pattern<'a>(