Skip to content

Commit c733274

Browse files
committed
Add type probe recording for ascriptions and update test description
1 parent 79cf327 commit c733274

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/language/dynamics/transition/Ascriptions.re

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@ module ClosureWriter =
2525
let append = (@);
2626
});
2727

28+
/* Record a sample for a probed type.
29+
* When a type has a probe on it (i.e., its ID is in targets), and we're
30+
* processing an ascription, we record the value being ascribed as a sample
31+
* for that type's probe. */
32+
let record_type_probe =
33+
(~targets: Sample.targets, typ: Typ.t, value: DHExp.t)
34+
: ClosureWriter.t(unit) => {
35+
let typ_id = Typ.rep_id(typ);
36+
switch (Id.Map.find_opt(typ_id, targets)) {
37+
| Some(spec) =>
38+
ClosureWriter.tell([
39+
(call_stack: Sample.call_stack, step_start: int, step_end: int) =>
40+
Sample.mk(
41+
~step_start,
42+
~step_end,
43+
typ_id,
44+
value,
45+
Environment.empty,
46+
call_stack,
47+
spec,
48+
),
49+
])
50+
| None => ClosureWriter.return()
51+
};
52+
};
53+
2854
let rec transition =
2955
(~recursive=false, ~targets: Sample.targets, d: DHExp.t)
3056
: ClosureWriter.t(option(DHExp.t)) => {
@@ -99,6 +125,8 @@ let rec transition =
99125
|> ClosureWriter.sequence;
100126
Some(IdTagged.fast_copy(DHExp.rep_id(e), Tuple(es) |> DHExp.fresh));
101127
| (_, Unknown(_)) =>
128+
/* Record sample if this type is probed */
129+
let* () = record_type_probe(~targets, t, e);
102130
let+ e = recur(e);
103131
Some(e);
104132
| (Cons(d1, d2), List(ty)) =>

test/evaluator/Test_Evaluator_Probes.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ in f(1)|},
821821
822822
*/
823823
probe_line_test(
824-
"Probe on function application with ascription",
824+
"Probe on type in ascription",
825825
{|3 : ^^probe(?)|},
826826
[(0, ["3"])],
827827
),

0 commit comments

Comments
 (0)