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

Use Dolmen locations in recoverable/fatal errors #1284

Merged
merged 6 commits into from
Feb 6, 2025

Conversation

Halbaroth
Copy link
Collaborator

This PR includes two modifications:

  1. Replacing Alt-Ergo locations from Loc to Dolmen.Std.Loc.loc.
  2. Using Dolmen locations in recoverable or fatal errors in Solving_loop (when it makes sense to print such locations).

@Halbaroth Halbaroth mentioned this pull request Feb 6, 2025
Copy link
Collaborator

@bclement-ocp bclement-ocp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible overall.

I think we might want to have a less verbose output for errors reported in (error) where using the Emacs format doesn't make that much sense; something terser like CVC5's file:line.columns: message would be better suited. We can iterate on the error messages themselves, however the escaping issue needs to be fixed (" should be displayed as "").


unknown

$ echo '(set-option :produce-models true) (set-logic ALL) (check-sat) (get-objectives)' | alt-ergo -i smtlib2 -o smtlib2 --continue-on-error --sat-solver Tableaux 2>/dev/null

unknown
(error "the selected solver does not support optimization")
(error "File "<stdin>", line 1, character 62-78:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not correct to have quotes inside strings in SMT-LIB format; they need to be replaced with double quotes "".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imported the function Dolmen.Std.Loc.fmt and adapted it. Yet, if the file name contains double quotes, they won't be escaped. I can write a function to handle them if you think it is important.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think that since this is a format that we are using to interoperate with tools (not just users) we should be robust here -- the escaping should ideally be done generically in print_smtlib_err. I will make a separate PR.

let rec aux acc (stmt: _ Typer_Pipe.stmt) =
let loc = Dolmen.Std.Loc.loc file stmt.loc in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Calling this st_loc would make it a bit less verbose to output the commands below.

Comment on lines 840 to 841
| {contents = `Other (custom, args); loc = l; _} ->
handle_custom_statement ~loc:l custom args st
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| {contents = `Other (custom, args); loc = l; _} ->
handle_custom_statement ~loc:l custom args st
| {contents = `Other (custom, args); loc; _} ->
handle_custom_statement ~loc custom args st

Copy link
Collaborator Author

@Halbaroth Halbaroth Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable st_loc already contains the location of the statement but the value Dolmen.Loc.compact is buggy (even its type is incorrect!), so we cannot transform a full location in handle_custom_statement into a compact location. Guillaume will address this issue in the next Dolmen release.

As a workaround, I passed the compact location of the statement itself here and used a different name for clarity. Actually the types are different, so shadowing wasn't that bad.

I applied your suggestion and add todo comment too.

@Halbaroth Halbaroth merged commit d1de99e into OCamlPro:next Feb 6, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants