Skip to content

Commit

Permalink
Emit error message on unsupported meta (and proof mode) commands
Browse files Browse the repository at this point in the history
Fixes #528
  • Loading branch information
maximedenes committed Jul 31, 2023
1 parent 0abe93b commit b069f20
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
21 changes: 15 additions & 6 deletions language-server/dm/executionManager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ let is_diagnostics_enabled () = !options.enableDiagnostics
let get_options () = !options

type prepared_task =
| PSkip of sentence_id
| PSkip of { id: sentence_id; error: string option }
| PExec of executable_sentence
| PQuery of executable_sentence
| PDelegate of { terminator_id: sentence_id;
Expand Down Expand Up @@ -311,7 +311,7 @@ let last_opt l = try Some (CList.last l).id with Failure _ -> None

let prepare_task task : prepared_task list =
match task with
| Skip id -> [PSkip id]
| Skip { id; error } -> [PSkip { id; error }]
| Exec e -> [PExec e]
| Query e -> [PQuery e]
| OpaqueProof { terminator; opener_id; tasks; proof_using} ->
Expand All @@ -329,7 +329,7 @@ let prepare_task task : prepared_task list =
[PExec terminator]

let id_of_prepared_task = function
| PSkip id -> id
| PSkip { id } -> id
| PExec ex -> ex.id
| PQuery ex -> ex.id
| PDelegate { terminator_id } -> terminator_id
Expand All @@ -340,7 +340,12 @@ let purge_state = function

(* TODO move to proper place *)
let worker_execute ~doc_id ~send_back (vs,events) = function
| PSkip _id ->
| PSkip { id; error = err } ->
let v = match err with
| None -> success vs
| Some msg -> error None msg vs
in
send_back (ProofJob.UpdateExecStatus (id,purge_state v));
(vs, events)
| PExec { id; ast; synterp; error_recovery } ->
let vs = { vs with Vernacstate.synterp } in
Expand Down Expand Up @@ -391,8 +396,12 @@ let execute st (vs, events, interrupted) task =
end else
try
match task with
| PSkip id ->
let st = update st id (success vs) in
| PSkip { id; error = err } ->
let v = match err with
| None -> success vs
| Some msg -> error None msg vs
in
let st = update st id v in
(st, vs, events, false)
| PExec { id; ast; synterp; error_recovery } ->
let vs = { vs with Vernacstate.synterp } in
Expand Down
6 changes: 3 additions & 3 deletions language-server/dm/scheduler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type executable_sentence = {
}

type task =
| Skip of sentence_id
| Skip of { id: sentence_id; error: string option }
| Exec of executable_sentence
| OpaqueProof of { terminator: executable_sentence;
opener_id: sentence_id;
Expand Down Expand Up @@ -197,8 +197,8 @@ let push_state id ast synterp classif st =
base_id st, push_ex_sentence ex_sentence st, Exec ex_sentence
| VtSideff _ ->
base_id st, extrude_side_effect ex_sentence st, Exec ex_sentence
| VtMeta -> assert false
| VtProofMode _ -> assert false
| VtMeta -> base_id st, push_ex_sentence ex_sentence st, Skip { id; error = Some "Unsupported command" }
| VtProofMode _ -> base_id st, push_ex_sentence ex_sentence st, Skip { id; error = Some "Unsupported command" }

(*
let string_of_task (task_id,(base_id,task)) =
Expand Down
2 changes: 1 addition & 1 deletion language-server/dm/scheduler.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type executable_sentence = {
}

type task =
| Skip of sentence_id
| Skip of { id: sentence_id; error: string option }
| Exec of executable_sentence
| OpaqueProof of { terminator: executable_sentence;
opener_id: sentence_id;
Expand Down

0 comments on commit b069f20

Please sign in to comment.