resolve integer underflow in @for
when both to and from and i32::MIN
This commit is contained in:
parent
f33739aa0f
commit
fac8b86a6a
@ -236,7 +236,7 @@ impl<'a> Parser<'a> {
|
|||||||
let from_val = self.parse_value_from_vec(from_toks, true)?;
|
let from_val = self.parse_value_from_vec(from_toks, true)?;
|
||||||
let from = match from_val.node {
|
let from = match from_val.node {
|
||||||
Value::Dimension(Some(n), ..) => match n.to_i32() {
|
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())
|
return Err((format!("{} is not an int.", n), from_val.span).into())
|
||||||
}
|
}
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
@ -254,7 +254,7 @@ impl<'a> Parser<'a> {
|
|||||||
let to_val = self.parse_value(true, &|_| false)?;
|
let to_val = self.parse_value(true, &|_| false)?;
|
||||||
let to = match to_val.node {
|
let to = match to_val.node {
|
||||||
Value::Dimension(Some(n), ..) => match n.to_i32() {
|
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())
|
return Err((format!("{} is not an int.", n), to_val.span).into())
|
||||||
}
|
}
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
|
@ -166,3 +166,7 @@ error!(
|
|||||||
to_nan,
|
to_nan,
|
||||||
"@for $i from 0 through (0/0) {}", "Error: NaN is not an int."
|
"@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."
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user