Skip to content

Commit

Permalink
Fix bug for short-to-int unary minus
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <[email protected]>
  • Loading branch information
mihaibudiu committed Nov 18, 2024
1 parent c71307d commit 6ecf3a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,7 @@ public static byte checkedUnaryMinus(byte b) {
}

public static short checkedUnaryMinus(short b) {
return intToShort(b);
return intToShort(-b);
}

public static int checkedUnaryMinus(int b) {
Expand Down
4 changes: 4 additions & 0 deletions core/src/test/resources/sql/cast.iq
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ select -2147483648 / -1;
Caused by: java.lang.ArithmeticException
!error

select -CAST(-32768 AS SMALLINT);
Caused by: java.lang.ArithmeticException: integer overflow: Value 32768 does not fit in a SMALLINT
!error

select CAST(32767 AS SMALLINT) + CAST(2 AS SMALLINT);
Caused by: java.lang.ArithmeticException: integer overflow: Value 32769 does not fit in a SMALLINT
!error
Expand Down

0 comments on commit 6ecf3a5

Please sign in to comment.