YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
26 stars 8 forks source link

Can we have DivisionByZeroException and a clean crash instead of silent "NaN" please? #7619

Open Grisgram opened 2 months ago

Grisgram commented 2 months ago

Is your feature request related to a problem?

Yes. The problem is, that in the early stages, where the code has many bugs, it can happen, that you divide by zero at one point, because you did something wrong with a variable, or did not think about it becoming zero.

Now, the runner silently ignores DivisionByZero and instead just sets "NaN" to any result of a calculation divided by zero.

It can be a cruel task to trace back to the root of this problem. If the game would just crash with a "division by zero", like C# and most other languages do, I would instantly be at the root point and could start my investigations, why this thing was zero.

Describe the solution you'd like

One of two things would be great:

Describe alternatives you've considered

There are none. If you run into this after the game reaches some complexity, it can be very hard to find the first point, where the value became NaN.

Additional context

No response

KormexGit commented 2 months ago

At the very least it'd be nice if built in variables like x, image_xscale, image_angle, etc. would crash when being set to NaN instead of what it currently does, which is let them be NaN and then crash with an invalid bbox value once you do anything that uses the collision mask. Not crashing until you do the collision check makes tracking the actual source of the issue down a pain, and if you haven't seen that error message before it'd be confusing what it even means.