Next: Color schemes, Previous: Verbose vs nonverbose messages, Up: Diagnostic output [Contents][Index]
Normally, the compiler prints all the diagnostics for a module together, in ascending order of context. (With the exception of Mercury modules whose source files use the ‘source_file’ pragma and/or the ‘#line’ directive, this means that messages for lower numbered lines are printed before messages for higher numbered lines.)
Sometimes, the output will look unsorted without actually being unsorted. This can happen because some diagnostics report an inconsistency between two or more parts of the program. Such diagnostics will contain one component for each such part, and each component’s text about that part will have before it the context (filename and line number) of that part. The sorting of diagnostics operates on just the first context in each diagnostic; any later contexts are ignored.
However, there are some situations in which the compiler does indeed intentionally deviate from the above default.
One such situation occurs when the programmer specifies the ‘-v’ option, which asks for verbose compiler output. In such cases, the compiler will print progress messages that specify which phase of compilation the compiler is about to start, and if that phase can find errors in the program, it will print the diagnostics for the errors it finds before it goes on to the next phase.
The programmer can ask for the usual ordering of diagnostics to be reversed by giving the ‘--reverse-error-order’ option. This options makes things easier for programmers when they want to work on the last errors in a file first. This can be a good idea for example if the module you are working on (e.g. by rearranging a data structure) has its primitive operations towards the end of the module, and you think the fixes needed to these primitives will require changes to their signatures. In such cases, fixing the lowest level primitives first allows you to fix the originally reported errors for higher level operations at the same time as you update their calls to the lower level primitives, and reversing the order of the diagnostics allows you to get to those errors for the tail end of the file without having to wade through the errors for the code above.
The compiler also supports a more general mechanism for allowing programmers to focus on fixing errors in a particular part of the program first. This mechanism is the ‘--limit-error-contexts’ compiler option. This option has as its argument a comma-separated list of line number ranges. It tells the compiler to print only diagnostics that contain one or more contexts that fall into one of these ranges. (A printed diagnostic may contain some contexts that fall outside all these ranges, as long as it has at least one context that falls inside.) If a compiler invocation has this option specified but all the diagnostics it would print in its absence are held back by this option, it will print a reminder about this fact.
Next: Color schemes, Previous: Verbose vs nonverbose messages, Up: Diagnostic output [Contents][Index]