Skip to content

Commit

Permalink
Don't instrument out-edges of assert false
Browse files Browse the repository at this point in the history
Fixes #355.
  • Loading branch information
aantron committed Nov 3, 2020
1 parent 4de17d7 commit 0223008
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/ppx/instrument.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,9 @@ class instrumenter =
instrument_expr ~use_loc_of:e' ~post:true e
end

| Pexp_assert [%expr false] ->
e

| Pexp_assert e ->
Exp.assert_ (traverse ~is_in_tail_position:false e)
|> instrument_expr ~use_loc_of:e ~post:true
Expand Down
8 changes: 8 additions & 0 deletions test/instrument/apply/assert.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ Out-edge instrumented.
let _ =
___bisect_post_visit___ 1
(assert (___bisect_post_visit___ 0 (bool_of_string "true")))
Not instrumented for assert false.
$ bash ../test.sh <<'EOF'
> let _ = assert false
> EOF
let _ = assert false
17 changes: 3 additions & 14 deletions test/instrument/recent/refutation.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,12 @@ instrumented.
___bisect_matched_value___
with
| `A ->
___bisect_visit___ 1;
___bisect_visit___ 0;
()
| `B ->
___bisect_visit___ 2;
___bisect_visit___ 1;
()
| _ -> ());
()
| (`C | `D) as ___bisect_matched_value___ ->
(match[@ocaml.warning "-4-8-9-11-26-27-28-33"]
___bisect_matched_value___
with
| `C ->
___bisect_visit___ 3;
()
| `D ->
___bisect_visit___ 4;
()
| _ -> ());
___bisect_post_visit___ 0 (assert false)
| `C | `D -> assert false
$ dune build ./test.bc --instrument-with bisect_ppx

0 comments on commit 0223008

Please sign in to comment.