get rid of spurious warning, add type error for skip_max_list
This commit is contained in:
@@ -1609,6 +1609,18 @@ pub enum IndexPtr {
|
||||
#[derive(Clone)]
|
||||
pub struct CodeIndex(pub Rc<RefCell<(IndexPtr, ClauseName)>>);
|
||||
|
||||
impl CodeIndex {
|
||||
pub fn is_undefined(&self) -> bool {
|
||||
let index_ptr = self.0.borrow().0;
|
||||
|
||||
if let IndexPtr::Undefined = index_ptr {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ModuleCodeIndex(pub IndexPtr, pub ClauseName);
|
||||
|
||||
|
||||
@@ -57,7 +57,10 @@ impl<'a> SubModuleUser for MachineCodeIndex<'a> {
|
||||
|
||||
fn insert_dir_entry(&mut self, name: ClauseName, arity: usize, idx: ModuleCodeIndex) {
|
||||
if let Some(ref mut code_idx) = self.code_dir.get_mut(&(name.clone(), arity)) {
|
||||
println!("warning: overwriting {}/{}", &name, arity);
|
||||
if !code_idx.is_undefined() {
|
||||
println!("warning: overwriting {}/{}", &name, arity);
|
||||
}
|
||||
|
||||
set_code_index!(code_idx, idx.0, idx.1);
|
||||
|
||||
return;
|
||||
|
||||
@@ -148,9 +148,14 @@ impl MachineState {
|
||||
} else {
|
||||
self.fail = true;
|
||||
},
|
||||
_ => {
|
||||
Addr::HeapCell(_) | Addr::StackCell(..) => {
|
||||
let stub = MachineError::functor_stub(clause_name!("$skip_max_list"), 4);
|
||||
return Err(self.error_form(MachineError::instantiation_error(), stub));
|
||||
},
|
||||
addr => {
|
||||
let stub = MachineError::functor_stub(clause_name!("$skip_max_list"), 4);
|
||||
return Err(self.error_form(MachineError::type_error(ValidType::Integer, addr),
|
||||
stub));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user