summary refs log tree commit diff stats
path: root/src/vm
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2022-10-31 12:52:54 -0300
committerSoniEx2 <endermoneymod@gmail.com>2022-10-31 12:53:14 -0300
commit7e37d5094bf9fdc47b6bf966e5b0568f695f34aa (patch)
tree3cf902f4d98fe9eab5c61c0d695a669715d98b08 /src/vm
parent94b73c41c6985e511806dbb43702ff85e8da4513 (diff)
Clean up
Diffstat (limited to 'src/vm')
-rw-r--r--src/vm/de.rs19
1 files changed, 11 insertions, 8 deletions
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"));
             },
             _ => (),
         }