Skip to content

Commit

Permalink
Fix failed cast ids
Browse files Browse the repository at this point in the history
  • Loading branch information
Negabinary committed Nov 15, 2024
1 parent 8e90861 commit 5d0629d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/haz3lcore/lang/term/Typ.re
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ let all_ids_temp = {
map_term(~f_exp=f, ~f_pat=f, ~f_typ=f, ~f_tpat=f, ~f_rul=f);
};

let (replace_temp, replace_temp_exp) = {
let f:
'a.
(IdTagged.t('a) => IdTagged.t('a), IdTagged.t('a)) => IdTagged.t('a)
=
(continue, exp) =>
{...exp, ids: exp.ids == [Id.invalid] ? [Id.mk()] : exp.ids}
|> continue;
(
map_term(~f_exp=f, ~f_pat=f, ~f_typ=f, ~f_tpat=f, ~f_rul=f),
TermBase.Exp.map_term(~f_exp=f, ~f_pat=f, ~f_typ=f, ~f_tpat=f, ~f_rul=f),
);
};

let hole = (tms: list(TermBase.Any.t)) =>
switch (tms) {
| [] => Unknown(Hole(EmptyHole))
Expand Down
3 changes: 2 additions & 1 deletion src/haz3lcore/statics/TermBase.re
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ and Exp: {
| Undefined => term
| MultiHole(things) => MultiHole(List.map(any_map_term, things))
| DynamicErrorHole(e, err) => DynamicErrorHole(exp_map_term(e), err)
| FailedCast(e, t1, t2) => FailedCast(exp_map_term(e), t1, t2)
| FailedCast(e, t1, t2) =>
FailedCast(exp_map_term(e), typ_map_term(t1), typ_map_term(t2))
| ListLit(ts) => ListLit(List.map(exp_map_term, ts))
| Fun(p, e, env, f) =>
Fun(pat_map_term(p), exp_map_term(e), env, f)
Expand Down
4 changes: 3 additions & 1 deletion src/haz3lweb/app/editors/result/EvalResult.re
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ module Update = {
NewValue(
Haz3lcore.ProgramResult.map(
({result: r, state: s}: Haz3lcore.ProgramResult.inner) => {
let exp = Haz3lcore.ProgramResult.Result.unbox(r);
let exp =
Haz3lcore.ProgramResult.Result.unbox(r)
|> Haz3lcore.DHExp.replace_all_ids;
(exp, s);
},
update,
Expand Down
10 changes: 7 additions & 3 deletions src/haz3lweb/app/editors/result/Stepper.re
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module Model = {
module Update = {
[@deriving (show({with_path: false}), sexp, yojson)]
type t =
// int here should include hidden steps
| StepperEditor(int, StepperEditor.Update.t)
| StepForward(int)
| StepBackward;
Expand Down Expand Up @@ -204,7 +205,8 @@ module Update = {
}
)
);
let next_expr = EvalCtx.compose(b.step.ctx, next_expr);
let next_expr =
EvalCtx.compose(b.step.ctx, next_expr) |> Typ.replace_temp_exp;
let editor = CodeWithStatics.Model.mk_from_exp(~settings, next_expr);
let next_steps = calc_next_steps(settings, next_expr, next_state);
(
Expand Down Expand Up @@ -291,6 +293,7 @@ module Update = {
|> {
let.calc elab = elab
and.calc settings = settings;
let elab = elab |> Typ.replace_temp_exp;
let editor = CodeWithStatics.Model.mk_from_exp(~settings, elab);
let next_steps =
calc_next_steps(settings, elab, EvaluatorState.init);
Expand Down Expand Up @@ -404,11 +407,12 @@ module View = {
stepper.history
|> Aba.aba_triples
|> (settings.core.evaluation.stepper_history ? x => x : (_ => []))
|> List.mapi((i, x) => (i, x))
|> (
settings.core.evaluation.show_hidden_steps
? x => x : List.filter(((_, b: Model.b, _)) => !b.hidden)
? x => x : List.filter(((_, (_, b: Model.b, _))) => !b.hidden)
)
|> List.mapi((i, (_, b: Model.b, a: Model.a)) =>
|> List.map(((i, (_, b: Model.b, a: Model.a))) =>
switch (a) {
| Calculated(a) =>
[
Expand Down

0 comments on commit 5d0629d

Please sign in to comment.