rusty icon indicating copy to clipboard operation
rusty copied to clipboard

Division by const 0 should be an error

Open mhasel opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. Currently, the following code compiles without warning/error:

FUNCTION foo: DINT
        foo := 1 / 0;
END_FUNCTION

Describe the solution you'd like We already mark expressions with zero on the right as unresolvable in const_evaluator.rs but don't report it. We should introduce a diagnostic, similar to the overflow-error, and warn the user that the expression will cause a runtime crash.

mhasel avatar Nov 09 '23 14:11 mhasel