resolve integer underflow in @for when both to and from and i32::MIN

This commit is contained in:
Connor Skees 2020-08-07 16:51:17 -04:00
parent f33739aa0f
commit fac8b86a6a
2 changed files with 6 additions and 2 deletions

View File

@ -236,7 +236,7 @@ impl<'a> Parser<'a> {
let from_val = self.parse_value_from_vec(from_toks, true)?;
let from = match from_val.node {
Value::Dimension(Some(n), ..) => match n.to_i32() {
Some(std::i32::MAX) | None => {
Some(std::i32::MAX) | Some(std::i32::MIN) | None => {
return Err((format!("{} is not an int.", n), from_val.span).into())
}
Some(v) => v,
@ -254,7 +254,7 @@ impl<'a> Parser<'a> {
let to_val = self.parse_value(true, &|_| false)?;
let to = match to_val.node {
Value::Dimension(Some(n), ..) => match n.to_i32() {
Some(std::i32::MAX) | None => {
Some(std::i32::MAX) | Some(std::i32::MIN) | None => {
return Err((format!("{} is not an int.", n), to_val.span).into())
}
Some(v) => v,

View File

@ -166,3 +166,7 @@ error!(
to_nan,
"@for $i from 0 through (0/0) {}", "Error: NaN is not an int."
);
error!(
to_and_from_i32_min,
"@for $i from -2147483648 through -2147483648 {}", "Error: -2147483648 is not an int."
);