]> Repositorios git - scryer-prolog.git/commitdiff
Fix xor/2 type error reporting wrong argument
authorManos Pitsidianakis <[email protected]>
Mon, 24 Oct 2022 16:26:43 +0000 (19:26 +0300)
committerManos Pitsidianakis <[email protected]>
Mon, 24 Oct 2022 16:26:43 +0000 (19:26 +0300)
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

src/machine/arithmetic_ops.rs

index d77283f1bf06608544e0a07694ba41cf48d19148..0a4eb6f45ce9fad7ad59e5b2a8c8891193689298 100644 (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)),
     }
 }