We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
2 parents0daa796 +eccc8d8 commit7138710Copy full SHA for 7138710
src/optimizer.rs
@@ -1034,7 +1034,7 @@ fn optimize_expr(expr: &mut Expr, state: &mut OptimizerState, _chaining: bool) {
1034
*expr =Expr::CharConstant(s.chars().nth(usize::try_from(*i).unwrap()).unwrap(),*pos);
1035
}
1036
// string[-int]
1037
-(Expr::StringConstant(s, pos),Expr::IntegerConstant(i, ..))if usize::try_from(i.unsigned_abs()).map(|x| x <= s.chars().count()).unwrap_or(false) =>{
+(Expr::StringConstant(s, pos),Expr::IntegerConstant(i, ..))if*i <0 &&usize::try_from(i.unsigned_abs()).map(|x| x <= s.chars().count()).unwrap_or(false) =>{
1038
// String literal indexing - get the character
1039
state.set_dirty();
1040
*expr =Expr::CharConstant(s.chars().rev().nth(usize::try_from(i.unsigned_abs()).unwrap() -1).unwrap(),*pos);