]> Repositorios git - scryer-prolog.git/commitdiff
correct sort/keysort refusing []
authorMark Thom <[email protected]>
Thu, 3 May 2018 23:36:59 +0000 (17:36 -0600)
committerMark Thom <[email protected]>
Thu, 3 May 2018 23:36:59 +0000 (17:36 -0600)
src/prolog/machine/machine_errors.rs
src/prolog/machine/machine_state_impl.rs

index 01a699fdd00b41e3cdf638fd93739a702a85d4ec..d2aa8702f68080fbfb9200de29a4a5702b0d2b17 100644 (file)
@@ -32,7 +32,7 @@ impl MachineState {
 
         match self.detect_cycles(usize::max_value(), sorted.clone()) {
             CycleSearchResult::NotList if !sorted.is_ref() =>
-                Err(self.error_form(self.type_error(ValidType::List, sorted))),
+                Err(self.error_form(self.type_error(ValidType::List, sorted))),            
             _ => Ok(())
         }
     }
index b6f0d1d35cc57177b7ff86799a1a2248d23e9010..e6ee1a28bee041fec3027796faeed66c05c2b114 100644 (file)
@@ -1724,8 +1724,10 @@ impl MachineState {
             },
             Addr::HeapCell(_) | Addr::StackCell(..) =>
                 Err(self.error_form(self.instantiation_error())),
-            addr =>
-                Err(self.error_form(self.type_error(ValidType::List, addr)))
+            Addr::Con(Constant::EmptyList) =>
+                Ok(vec![]),
+            _ =>
+                Err(self.error_form(self.type_error(ValidType::List, a1)))
         }
     }
 
@@ -1781,7 +1783,10 @@ impl MachineState {
                 },
                 HeapCellValue::Addr(Addr::Con(Constant::EmptyList)) =>
                     return CycleSearchResult::ProperList(steps),
-                _ => return CycleSearchResult::PartialList(steps, hare)
+                HeapCellValue::Addr(Addr::HeapCell(_)) | HeapCellValue::Addr(Addr::StackCell(..)) =>
+                    return CycleSearchResult::PartialList(steps, hare),
+                _ =>
+                    return CycleSearchResult::NotList
             }
         }
     }