From 7e37d5094bf9fdc47b6bf966e5b0568f695f34aa Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Mon, 31 Oct 2022 12:52:54 -0300 Subject: Clean up --- src/vm/de.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/vm/de.rs b/src/vm/de.rs index 85a24fb..c0bc853 100644 --- a/src/vm/de.rs +++ b/src/vm/de.rs @@ -120,7 +120,7 @@ impl<'pat, 'state, 'de, O: Serialize> Packer<'pat, 'state, O> { self.call_limit -= 1; } else { self.interp.error.insert(MatchError::StackOverflow); - return Err(todo!()); + return Err(E::custom("stack overflow")); } // iterate up to the *live* length (i.e. the loop is allowed to modify // the length). @@ -135,7 +135,7 @@ impl<'pat, 'state, 'de, O: Serialize> Packer<'pat, 'state, O> { // overstepped and non-matching frames frame.overstep += 1; // FIXME check if this is correct (it probably isn't) - frame.matches = false; + //frame.matches = false; } else { if !frame.next() { // empty/end-of frames @@ -143,6 +143,8 @@ impl<'pat, 'state, 'de, O: Serialize> Packer<'pat, 'state, O> { // step-out will undo this. // this is correct because this branch implies overstep = 0 frame.overstep = 1; + // FIXME we still don't think this is correct + frame.matches = false; } else if matches!( frame.op(), PatternElement::SubtreeMarker, @@ -284,13 +286,15 @@ where Type::IgnoredAny, |target_type, frame| { Ok(match (target_type, frame.get_type()) { - // FIXME handle None correctly // required type binds stronger than any/ignored_any (Type::IgnoredAny, Some((ty, true))) => ty, (Type::Any, Some((ty, true))) => ty, // and also stronger than optional any/ignored_any (ty, Some((Type::IgnoredAny, _))) => ty, (ty, Some((Type::Any, _))) => ty, + // None effectively falls back into any + (Type::IgnoredAny, None) => Type::Any, + (ty, None) => ty, // prefer owned if any branch prefers owned (Type::String, Some((Type::Str, true))) => { Type::String @@ -316,7 +320,6 @@ where (left, Some((right, _))) => { return Err(MatchError::Unsatisfiable); }, - _ => Type::Any, }) }, ); @@ -437,7 +440,7 @@ macro_rules! vs { match result { Err(e) => { $this.interp.error.insert(e); - return Err(todo!()); + return Err(serde::de::Error::custom("type mismatch")); }, _ => (), } @@ -548,7 +551,7 @@ where match result { Err(e) => { self.interp.error.insert(e); - return Err(todo!()); + return Err(E::custom("type/value mismatch")); }, _ => (), } @@ -631,7 +634,7 @@ where match result { Err(e) => { self.interp.error.insert(e); - return Err(todo!()); + return Err(E::custom("type/value mismatch")); }, _ => (), } @@ -731,7 +734,7 @@ where match typeck { Err(e) => { self.interp.error.insert(e); - return Err(todo!()); + return Err(A::Error::custom("type mismatch")); }, _ => (), } -- cgit 1.4.1