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:
@@ -99,8 +99,8 @@ let pp_expression node_name =
|
|||||||
match expression with
|
match expression with
|
||||||
| EWhen (_, e1, e2) ->
|
| EWhen (_, e1, e2) ->
|
||||||
begin
|
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 ? %a : 0"
|
||||||
Format.fprintf fmt "%a"
|
pp_expression_aux e2
|
||||||
pp_expression_aux e1
|
pp_expression_aux e1
|
||||||
end
|
end
|
||||||
| EReset (_, e1, e2) ->
|
| EReset (_, e1, e2) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user