pub(super) fn check_sort_errors(&mut self) -> CallResult {
        let stub_gen = || functor_stub(atom!("sort"), 2);

        let list = self.store(self.deref(self.registers[1]));
        let sorted = self.store(self.deref(self.registers[2]));

        match BrentAlgState::detect_cycles(&self.heap, list) {
            CycleSearchResult::PartialList(..) => {
                let err = self.instantiation_error();
                return Err(self.error_form(err, stub_gen()))
            }
            CycleSearchResult::NotList(..) | CycleSearchResult::Cyclic(_) => {
                let err = self.type_error(ValidType::List, list);
                return Err(self.error_form(err, stub_gen()));
            }
            _ => {}
        };

        match BrentAlgState::detect_cycles(&self.heap, sorted) {
            CycleSearchResult::NotList(..) | CycleSearchResult::Cyclic(_) if !sorted.is_var() => {
                let err = self.type_error(ValidType::List, sorted);
                Err(self.error_form(err, stub_gen()))
            }
            _ => Ok(()),
        }
    }
// see 8.4.3 of Draft Technical Corrigendum 2.
see 8.4.3 of Draft Technical Corrigendum 2.
see 8 . 4 . 3 of Draft Technical Corrigendum 2 .
pub(super) fn check_sort_errors(&mut self) -> CallResult {
        let stub_gen = || functor_stub(atom!("sort"), 2);
        let list = self.store(self.deref(self.registers[1]));
        let sorted = self.store(self.deref(self.registers[2]));
        match BrentAlgState::detect_cycles(&self.heap, list) {
            CycleSearchResult::PartialList(..) => {
                let err = self.instantiation_error();
                return Err(self.error_form(err, stub_gen()))
            }
            CycleSearchResult::NotList(..) | CycleSearchResult::Cyclic(_) => {
                let err = self.type_error(ValidType::List, list);
                return Err(self.error_form(err, stub_gen()));
            }
            _ => {}
        };
        match BrentAlgState::detect_cycles(&self.heap, sorted) {
            CycleSearchResult::NotList(..) | CycleSearchResult::Cyclic(_) if !sorted.is_var() => {
                let err = self.type_error(ValidType::List, sorted);
                Err(self.error_form(err, stub_gen()))
            }
            _ => Ok(()),
        }
    }
pub ( super ) fn check_sort_errors ( & mut self ) -> CallResult { let stub_gen = | | functor_stub ( atom ! ( " " ) , 2 ) ; let list = self . store ( self . deref ( self . registers [ 1 ] ) ) ; let sorted = self . store ( self . deref ( self . registers [ 2 ] ) ) ; match BrentAlgState :: detect_cycles ( & self . heap , list ) { CycleSearchResult :: PartialList ( .. ) => { let err = self . instantiation_error ( ) ; return Err ( self . error_form ( err , stub_gen ( ) ) ) } CycleSearchResult :: NotList ( .. ) | CycleSearchResult :: Cyclic ( _ ) => { let err = self . type_error ( ValidType :: List , list ) ; return Err ( self . error_form ( err , stub_gen ( ) ) ) ; } _ => { } } ; match BrentAlgState :: detect_cycles ( & self . heap , sorted ) { CycleSearchResult :: NotList ( .. ) | CycleSearchResult :: Cyclic ( _ ) if ! sorted . is_var ( ) => { let err = self . type_error ( ValidType :: List , sorted ) ; Err ( self . error_form ( err , stub_gen ( ) ) ) } _ => Ok ( ( ) ) , } }
see 8.4.3 of Draft Technical Corrigendum 2.
see 8 . 4 . 3 of Draft Technical Corrigendum 2 .
&mut self
&mut self