From: Manos Pitsidianakis Date: Mon, 24 Oct 2022 16:26:43 +0000 (+0300) Subject: Fix xor/2 type error reporting wrong argument X-Git-Tag: v0.9.1~2^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=a9a06b5297e75f2d0eefbee653c5788cb7932062;p=scryer-prolog.git 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 --- diff --git a/src/machine/arithmetic_ops.rs b/src/machine/arithmetic_ops.rs index d77283f1..0a4eb6f4 100644 --- a/src/machine/arithmetic_ops.rs +++ b/src/machine/arithmetic_ops.rs @@ -793,7 +793,8 @@ pub(crate) fn xor(n1: Number, n2: Number, arena: &mut Arena) -> Result { 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)), } }