diff --git a/core/translate/expr.rs b/core/translate/expr.rs index 3f82940bb..6520a8b14 100644 --- a/core/translate/expr.rs +++ b/core/translate/expr.rs @@ -1850,7 +1850,7 @@ pub fn translate_expr( } ast::Expr::Literal(lit) => match lit { ast::Literal::Numeric(val) => { - if val.starts_with("0x") { + if val.starts_with("0x") || val.starts_with("0X") { // must be a hex decimal let int_value = i64::from_str_radix(&val[2..], 16)?; program.emit_insn(Insn::Integer { @@ -1942,15 +1942,14 @@ pub fn translate_expr( // If we don't do this -1 * 9223372036854775808 will overflow and parse will fail // and trigger conversion to Real. if numeric_value == "9223372036854775808" - || numeric_value == "0x7fffffffffffffff" - || numeric_value == "0x7FFFFFFFFFFFFFFF" + || numeric_value.to_lowercase() == "0x7fffffffffffffff" { program.emit_insn(Insn::Integer { value: i64::MIN, dest: target_register, }); } else { - if numeric_value.starts_with("0x") { + if numeric_value.starts_with("0x") || numeric_value.starts_with("0X") { // must be a hex decimal let int_value = i64::from_str_radix(&numeric_value[2..], 16)?; program.emit_insn(Insn::Integer { @@ -1991,7 +1990,7 @@ pub fn translate_expr( Ok(target_register) } (UnaryOperator::BitwiseNot, ast::Expr::Literal(ast::Literal::Numeric(num_val))) => { - if num_val.starts_with("0x") { + if num_val.starts_with("0x") || num_val.starts_with("0X") { let int_value = i64::from_str_radix(&num_val[2..], 16)?; program.emit_insn(Insn::Integer { value: !int_value,