Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit error message on unsupported meta (and proof mode) commands #530

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion language-server/tests/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ let task : type a. Scheduler.task -> a task_approx -> (a,string) Result.t =
fun t spec ->
match spec, t with
| Exec, Exec { id } -> Ok id
| Skip, Skip id -> Ok id
| Skip, Skip { id } -> Ok id
| Query, Query { id } -> Ok id
| Proof c, OpaqueProof { tasks; opener_id; terminator } ->
count (List.map ~f:(fun x -> x.id) tasks) c >>= (fun l ->
Expand Down
Loading