fixes for issues #185 and #181

This commit is contained in:
Mark Thom
2019-10-04 20:03:03 -06:00
parent 1569cac98f
commit 3fa168d35b
6 changed files with 22 additions and 15 deletions

View File

@@ -18,7 +18,7 @@ lazy_static = "1.4.0"
libc = "0.2.62"
nix = "0.15.0"
ordered-float = "0.5.0"
prolog_parser = "0.8.31"
prolog_parser = "0.8.32"
ref_thread_local = "0.0.0"
rug = "1.4.0"
rustyline = "5.0.3"

View File

@@ -542,10 +542,10 @@ impl ClauseType {
match self {
&ClauseType::Op(_, ref spec, _) => Some(spec.clone()),
&ClauseType::Inlined(InlinedClauseType::CompareNumber(..))
| &ClauseType::BuiltIn(BuiltInClauseType::Is(..))
| &ClauseType::BuiltIn(BuiltInClauseType::CompareTerm(_))
| &ClauseType::BuiltIn(BuiltInClauseType::NotEq)
| &ClauseType::BuiltIn(BuiltInClauseType::Eq) => Some(SharedOpDesc::new(700, XFX)),
| &ClauseType::BuiltIn(BuiltInClauseType::Is(..))
| &ClauseType::BuiltIn(BuiltInClauseType::CompareTerm(_))
| &ClauseType::BuiltIn(BuiltInClauseType::NotEq)
| &ClauseType::BuiltIn(BuiltInClauseType::Eq) => Some(SharedOpDesc::new(700, XFX)),
_ => None,
}
}

View File

@@ -280,6 +280,15 @@ pub fn fetch_op_spec(
spec: Option<SharedOpDesc>,
op_dir: &OpDir,
) -> Option<SharedOpDesc> {
if let Some(ref op_desc) = &spec {
if op_desc.arity() != arity {
/* it's possible to extend operator functors with
* additional terms. When that happens,
* void the op_spec by returning None. */
return None;
}
}
spec.or_else(|| match arity {
2 => op_dir
.get(&(name, Fixity::In))

View File

@@ -922,7 +922,9 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
match heap_val {
HeapCellValue::NamedStr(arity, name, spec) => {
if let Some(spec) = fetch_op_spec(name.clone(), arity, spec.clone(), self.op_dir) {
let spec = fetch_op_spec(name.clone(), arity, spec.clone(), self.op_dir);
if let Some(spec) = spec {
self.handle_op_as_struct(
name,
arity,

View File

@@ -1114,7 +1114,7 @@ impl MachineState {
}
fn pow(&self, n1: Number, n2: Number, culprit: &'static str) -> Result<Number, MachineStub> {
if n2.is_negative() {
if n2.is_negative() && n1.is_zero() {
let stub = MachineError::functor_stub(clause_name!(culprit), 2);
return Err(self.error_form(MachineError::evaluation_error(EvalError::Undefined), stub));
}

View File

@@ -31,13 +31,9 @@
!.
'$print_exception'(E) :-
( E = error(_, _:_) -> true % if the error source contains a line
% number, a GNU-style error message
% is expected to be printed instead.
; write_term('caught: ', [quoted(false)]),
writeq(E),
nl
).
write_term('caught: ', [quoted(false)]),
writeq(E),
nl.
'$predicate_indicator'(Source, PI) :-
( nonvar(PI) ->