Avoid crashes that can occur when using when with a statement that may crash if the when condition doesn't hold

For instance

```
node main () returns (o: int);
var i: int;
let
    i = 0;
    o = (1 / i) when false;
tel
```

used to crash with for instance:

```
Floating point exception
136
```

now returns `0` but in fact this value wouldn't be used in theory as the `when` condition doesn't hold.
This commit is contained in:
Benjamin Loison 2022-12-15 23:22:15 +01:00
parent 74f8a3c3e1
commit bfca80bb8b

View File

@ -99,8 +99,8 @@ let pp_expression node_name =
match expression with
| EWhen (_, e1, e2) ->
begin
(* as don't use a variable assigned when the condition holds, can define it even if the condition doesn't hold *)
Format.fprintf fmt "%a"
Format.fprintf fmt "%a ? %a : 0"
pp_expression_aux e2
pp_expression_aux e1
end
| EReset (_, e1, e2) ->