fix sign error in shl on fixnum with n >= 63 (#499)

This commit is contained in:
Mark Thom
2020-05-16 23:00:37 -06:00
parent 05d3b97eae
commit 69706ecab0
3 changed files with 40 additions and 26 deletions

View File

@@ -781,8 +781,13 @@ impl MachineState {
match (n1, n2) {
(Number::Fixnum(n1), Number::Fixnum(n2)) => {
if let Ok(n2) = u32::try_from(n2) {
if let Some(result) = n1.checked_shl(n2) {
return Ok(Number::from(result));
if n2 < 63 {
if let Some(result) = n1.checked_shl(n2) {
return Ok(Number::from(result));
}
} else {
let n1 = Integer::from(n1);
return Ok(Number::from(n1 << n2));
}
}