Repeating a negative amount of times repeats forever

Use this template to make awesome bug reports:

Your username: Petrichor ‮

What kind of device are you using?: iPhone 8

1 sentence description of the problem (I was doing _________, and then __________ happened): If you put a negative number in the parameter for a repeat block, it repeats forever.

Steps that the Hopscotch team can take to reproduce my problem every time:

  1. Repeat -1 times

….

I expected this to happen: nothing

But instead this happened: lots of something

Here’s a sweet screenshot:

13 Likes

Wow, I never tried doing that before. Very interesting.

It goes to show that -1 is truly infinite lol.

7 Likes

all hail -1

9 Likes

No

4 Likes

÷4 or +2. Take it or leave it. I have also never seen that happen before. I’m pretty sure it takes it as an invalid number, which means it should go error, but since it IS a number, it can’t repeat -1 times, so it repeats forever searching for the number -1.

3 Likes

whoa -1 truly is powerful

4 Likes

It could be as simple as a javascript logic error, though I’d have to check the code to see if that is the issue.

for (i = 0; i != -1; i++;) {
   console.log("test");
}

The code above will never end and possibly hang the browser tab. It should be <-1 instead of !=-1 in my case.

6 Likes

:bowing_woman::bowing_woman::bowing_woman::bowing_woman::bowing_woman::bowing_woman: This is proof.

4 Likes

I’m pretty sure this isn’t a bug, but an incorrect programming error.

3 Likes

that’s literally what bugs are, but incorrect programming errors are correct because an incorrect error doesn’t result in an error

7 Likes

-1 is infinite

Although THT should fix this - if we don’t it will drive +2 away and then we will have no one to rule over

6 Likes

Well now all I can imagine is the Imperial March with -1 as Darth Vader lol

3 Likes

Loops always start at 0 and count up. It will keep going up in the positives until it overflows at around 2.17 billion, then it counts up from -2.17 billion.

So it is actually repeating 4,294,967,295 times.

2 Likes

In other words, it repeats forever.

4 Likes

Yes, it does feel like forever. In fact, it won’t even end for more than 100 years most likely.

2 Likes

See
-1 doesn’t make sense.
But why does this happen lol

Possible explanation ↓

1 Like

Yeah
If it was replaced with what you say, then repeat times -n would do nothing.
(Here n is any number you want)

This is really strange!

1 Like