package libsail
Module Libsail.ReportingSource
Sail error reporting
Reporting contains functions to report errors and warnings. It contains functions to print locations (Parse_ast.l and Ast.l) and lexing positions.
The main functionality is reporting errors. This is done by raising a Fatal_error exception. This is caught internally and reported via report_error. There are several predefined types of errors which all cause different error messages. If none of these fit, Err_general can be used.
How many backtrace entries to show for unreachable code errors
Auxiliary Functions
loc_to_string prints a location as a string, including source code
loc_file returns the file for a location
Reduce a location to a pair of positions if possible
short_loc_to_string prints the location as a single line in a simple format
print_err prints a custom error message to stderr.
Reduce all spans in a location to just their starting characters
The error type
type error = private | Err_general of Parse_ast.l * string(*General errors, used for multi purpose. If you are unsure, use this one.
*)| Err_unreachable of Parse_ast.l * string * int * int * int * Printexc.raw_backtrace * string(*Unreachable errors should never be thrown. They represent an internal Sail error.
*)| Err_todo of Parse_ast.l * string(*
*)Err_todoindicates that some feature is unimplemented.| Err_syntax of Lexing.position * string| Err_syntax_loc of Parse_ast.l * string(*
*)Err_syntaxandErr_syntax_locare used for syntax errors by the parser.| Err_lex of Lexing.position * string(*
*)Err_lexis a lexical error generated by the lexer.| Err_type of Parse_ast.l * string option * string(*
*)Err_typeis a type error. See the Type_error module.
Errors stop execution and print a message; they typically have a location and message.
Note that all these errors are intended to be fatal, so should not be caught other than by the top-level function.
Raise an unreachable exception.
This should always be used over an assert false or a generic OCaml failwith exception when appropriate
This function transforms all errors raised by the provided function into internal Err_unreachable errors
Print a warning message. The first string is printed before the location, the second after.
val format_warn :
?once_from:(string * int * int * int) ->
string ->
Parse_ast.l ->
Error_format.message ->
unitPrint a simple one-line warning without a location.
Will suppress all warnings for a given (Sail) file name. Used by $suppress_warnings directive in process_file.ml