File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ fn bit_op() {
108108 check_fail ( r#"const GOAL: i8 = 1 << 8"# , |e| {
109109 e == ConstEvalError :: MirEvalError ( MirEvalError :: Panic ( "Overflow in Shl" . to_string ( ) ) )
110110 } ) ;
111+ check_number ( r#"const GOAL: i32 = 100000000i32 << 11"# , ( 100000000i32 << 11 ) as i128 ) ;
111112}
112113
113114#[ test]
Original file line number Diff line number Diff line change @@ -1037,13 +1037,18 @@ impl Evaluator<'_> {
10371037 BinOp :: Shr => l128. checked_shr ( shift_amount) ,
10381038 _ => unreachable ! ( ) ,
10391039 } ;
1040+ if shift_amount as usize >= lc. len ( ) * 8 {
1041+ return Err ( MirEvalError :: Panic ( format ! (
1042+ "Overflow in {op:?}"
1043+ ) ) ) ;
1044+ }
10401045 if let Some ( r) = r {
10411046 break ' b r;
10421047 }
10431048 } ;
10441049 return Err ( MirEvalError :: Panic ( format ! ( "Overflow in {op:?}" ) ) ) ;
10451050 } ;
1046- check_overflow ( r ) ?
1051+ Owned ( r . to_le_bytes ( ) [ ..lc . len ( ) ] . to_vec ( ) )
10471052 }
10481053 BinOp :: Offset => not_supported ! ( "offset binop" ) ,
10491054 }
You can’t perform that action at this time.
0 commit comments