library/string.format.m:
We used to parse format strings, and pair up format specifiers with
the list of input poly_types, using semidet code, throwing
exceptions with generic messages if the semidet code failed.
This diff switches to using det code that returns a list of
situation-specific error messages. Since errors after the first
may be caused by the first error, we now throw exceptions whose
message is a detailed description of the first error, but that
decision is easily changeable.
Simplify some existing code.
tests/general/string_format_test_{2,3}.{exp,exp2,exp3,...}:
tests/invalid/string_format_bad.err_exp:
tests/invalid/string_format_unknown.err_exp:
Update the expected error messages.
Estimated hours taken: 16
Branches: main
Give the compiler the capability of detecting errors that manifest themselves
as mismatches between the format string and the list of values to be printed
in calls to string.format and io.format.
This capability is controlled through two new options:
--warn-known-bad-format-calls
--warn-unknown-format-calls
The first (which will default to "on" once this change has bootstrapped)
controls whether the compiler emits warnings for statically known mismatches.
The second (which will default to "off") controls whether the compiler emits
warnings in cases where either the format string or the structure of the list
of values to be printed is not available statically to be checked.
NEWS:
Mention the new capability.
compiler/options.m:
Add the two new options.
doc/user_guide.texi:
Document the new options.
compiler/format_call.m:
New module to implement the new capability.
compiler/notes/compiler_structure.html:
Document the new module.
compiler/check_hlds.m:
Include the new module.
compiler/simplify.m:
Invoke the new module if the procedure being processed contains calls
to string.format or io.format.
Fix an old bug: we could generate warnings or even errors when
simplifying predicate bodies imported from other modules via
intermodule optimization.
Don't export get/set predicates that do not need to be exported.
compiler/det_report.m:
Add new kinds of error specifications for the errors detected by the
new module.
Separate out the context of each error specification, in order
to allow the error messages to be sorted by context; this makes
the output much easier to read.
compiler/common.m:
compiler/det_analysis.m:
compiler/simplify.m:
Conform to the change to det_report.m.
mdbcomp/prim_data.m:
Add a utility function for forming the possibly qualified names of
library modules (such as "io" and "string").
library/Mercury.options:
compiler/Mercury.options:
Add the lines that disable the new checks in the modules that need them
disabled. The new lines are commented out until installed compilers all
understand them, at which point in time we will add the requirement to
understand the option to configure.in.
compiler/fact_table.m:
compiler/mlds_to_il.m:
Fix three bugs reported by the new check that have apparently escaped
detection all this time.
library/rtti_implementation.m:
Change some code to avoid a spurious warning from the new checks.
library/string.m:
Rename a predicate to avoid an unnecessary and confusing overloading of
its name.
Replace __ with . as module qualifier connective.
compiler/handle_options.m:
library/pprint.m:
Misc cleanups.
tests/invalid/string_format_bad.{m,err_exp}:
tests/invalid/string_format_unknown.{m,err_exp}:
New test cases to test the new warnings.
tests/invalid/Mmakefile:
tests/invalid/Mercury.options:
Enable the new test cases.
tests/general/string_format_test*.exp*:
Update any expected abort messages to expect . instead of __ as module
qualifier connective.
tests/invalid/det_errors_cc.err_exp:
tests/invalid/erroneous_throw_promise.err_exp:
tests/warnings/simple_code.exp:
Expect the same error messages in program context order.
Estimated hours taken: 14
Branches: main
Change the compiler and tools so that `.' and not `:' is now used as the
module separator in all output.
Infix `.' now has associativity yfx and priority 10.
NEWS:
Report the change.
configure.in:
Amend the test for an up-to-date Mercury compiler to check whether
it recognises `.' as a module qualifier.
compiler/code_gen.m:
compiler/error_util.m:
compiler/hlds_out.m:
compiler/prog_out.m:
compiler/prog_util.m:
compiler/rl_exprn.m:
compiler/rl_gen.m:
compiler/source_file_map.m:
compiler/unused_args.m:
library/io.m:
library/rtti_implementation.m:
library/type_desc.m:
runtime/mercury_debug.c:
runtime/mercury_deconstruct.c:
runtime/mercury_stack_trace.c:
Change `:' to `.' as module separator for output.
compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
As above.
Fixed a bug where `.' was not being recognised as a module separator.
doc/reference_manual.texi:
Report the change.
library/term_io.m:
Ensure that infix `.' is written without surrounding spaces.
tests/hard_coded/dot_separator.m:
tests/hard_coded/dot_separator.exp:
tests/hard_coded/Mmakefile:
Test case added.
Estimated hours taken: 0.3
Branches: main
Fix the expected test results to reflect the new implementation changes
to exception.m
tests/general/string_format_test_2.exp2:
tests/general/string_format_test_3.exp2:
tests/hard_coded/no_fully_strict.exp2:
tests/hard_coded/exceptions/test_uncaught_exception.exp2:
tests/tabling/loopcheck.exp2:
Add throw_impl to the stack trace.
Estimated hours taken: 1
tests/general/float_test.exp:
tests/general/string_format_test.exp:
tests/general/string_format_test.m:
tests/general/string_format_test_2.exp:
tests/general/string_format_test_2.exp2:
tests/general/string_format_test_2.exp3:
tests/general/string_format_test_3.exp:
tests/general/string_format_test_3.exp2:
tests/general/string_format_test_3.exp3:
tests/hard_coded/string_loop.exp:
Changes required to the test cases for the new string__format.
Estimated hours taken: 0.25
tests/general/Mmakefile:
tests/general/string_format_test_2.exp2:
tests/general/string_format_test_3.exp2:
Avoid hard-coding dependencies on line numbers
within the standard library source code in
the test case output for these two tests.
Estimated hours taken: 0.5
tests/debugger/browser_test.exp2:
tests/general/string_format_test_2.exp2:
tests/general/string_format_test_3.exp2:
Update the line numbers for io.m to reflect my recent change
to io.m. (This will be a real maintenance problem... in the
long term, we should find a better solution, e.g. compiling
these test cases with line number information disabled.)
Estimated hours taken: 1
Compile the files in the library directory with --trace minimum by default,
which has no effect in non-debugging grades and causes the library to be
shallow traced, not deep traced, in debugging grades.
This is probably what most users want, and it makes it much easier to
maintain the expected output of the debugging test cases in debugging grades.
library/Mmakefile:
Add --trace minimum to MCG.
tests/*/*:
Update the test cases both for this change and for my previous change,
the addition of line numbers.
Estimated hours taken: 0.1
tests/general/string_format_test_2.exp2:
tests/general/string_format_test_3.exp2:
tests/hard_coded/no_fully_strict.exp2:
Update the expected output of these tests cases when stack trace is
enabled to reflect that error now throws exceptions.
Estimated hours taken: 0.1
Update tests to reflect that error now throws an exception.
general/string_format_test_2.exp:
general/string_format_test_2.exp2:
general/string_format_test_3.exp:
general/string_format_test_3.exp2:
Estimated hours taken: 0.25
Fix some spurious test cases failures for the debugging test cases.
tests/debugger/*.exp2:
Add alternative expected outputs for the test cases that
produce different results when built in debug grades (i.e.
when linked with a library was built with debugging enabled).
Estimated hours taken: 0.5
tests/Mmake.common:
Allow test cases to have more than one expected output.
tests/general/string_format_test_2.exp2:
tests/general/string_format_test_3.exp2:
tests/hard_coded/no_fully_strict.exp2:
Add alternative expected output for these
test cases, since the output is different
depending on whether or not the program is
compiled in a grade that supports stack traces.