Fix xor/2 type error reporting wrong argument

If first argument n1 in xor/2 is of wrong numerical type, the match
patterns fall through to a catch all case that reports the second
argument in the type error.

Fixes #1626

`xor/2 function reports the wrong argument in type error #1626`

https://github.com/mthom/scryer-prolog/issues/1626
This commit is contained in:
Manos Pitsidianakis
2022-10-24 19:26:43 +03:00
parent 6b8e620495
commit a9a06b5297

View File

@@ -793,7 +793,8 @@ pub(crate) fn xor(n1: Number, n2: Number, arena: &mut Arena) -> Result<Number, M
(Number::Integer(_), n2) | (Number::Fixnum(_), n2) => {
Err(numerical_type_error(ValidType::Integer, n2, stub_gen))
}
_ => Err(numerical_type_error(ValidType::Integer, n2, stub_gen)),
(n1, Number::Integer(_)) => Err(numerical_type_error(ValidType::Integer, n1, stub_gen)),
_ => Err(numerical_type_error(ValidType::Integer, n1, stub_gen)),
}
}