core icon indicating copy to clipboard operation
core copied to clipboard

Bug about range

Open chaijie2018 opened this issue 10 months ago • 5 comments

for i in 9..=0 {
  println(i)
}

Range does not support iterating from large to small, but there is no compilation error.

chaijie2018 avatar Apr 22 '25 08:04 chaijie2018

How could the compiler knows if you have:

let start = fetch("www.example.com/a/number").await!()
let end = fetch("www.example.com/another/number").await!()
for i in start..<end {
}

peter-jerry-ye avatar Apr 23 '25 02:04 peter-jerry-ye

At least we can report warning on constant one?

hackwaly avatar Apr 23 '25 07:04 hackwaly

Then should we report warning for these cases as well

for i = 0; i < 0; i = i + 1 {
}
for i = 0; i < -1; i = i + 1 {
}
while false {
}

peter-jerry-ye avatar Apr 23 '25 09:04 peter-jerry-ye

I think this is a lint issue, shouldn't it be reported at the compiler level?

Lampese avatar Aug 17 '25 19:08 Lampese

Since it's a lint issue, we'll handle it with linter @myfreess

peter-jerry-ye avatar Sep 25 '25 07:09 peter-jerry-ye