Commit Graph

14 Commits

Author SHA1 Message Date
Zoltan Somogyi
52ffbd1057 Generate better error messages for string.format.
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.
2014-11-15 19:38:53 +11:00
Zoltan Somogyi
b819fbc0a6 Give the compiler the capability of detecting errors that manifest themselves
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.
2006-01-27 05:52:27 +00:00
Ralph Becket
a8ffd3680c Change the compiler and tools so that .' and not :' is now used as the
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.
2003-01-17 05:57:20 +00:00
Simon Taylor
72aa0f1613 Update expected output after Zoltan's shallow tracing change.
Estimated hours taken: 0.25
Branches: main

tests/general/string_format_test_2.exp2:
tests/general/string_format_test_3.exp2:
	Update expected output after Zoltan's shallow tracing change.
2002-08-06 06:46:54 +00:00
Peter Ross
1167698388 Changes now that we report that an Uncaught exception comes
Estimated hours taken: 3
Branches: main


debugger/exception_cmd.exp:
debugger/exception_cmd.exp2:
debugger/exception_vars.exp:
debugger/exception_vars.exp2:
debugger/loopcheck.exp:
debugger/loopcheck.exp2:
debugger/polymorphic_output.exp:
debugger/polymorphic_output.exp2:
debugger/polymorphic_output.exp3:
general/string_format_test_2.exp:
general/string_format_test_2.exp2:
general/string_format_test_2.exp3:
general/string_format_test_2.exp4:
general/string_format_test_3.exp:
general/string_format_test_3.exp2:
general/string_format_test_3.exp3:
general/string_format_test_3.exp4:
hard_coded/foreign_type.m:
hard_coded/no_fully_strict.exp:
hard_coded/no_fully_strict.exp2:
hard_coded/no_fully_strict.exp3:
hard_coded/no_fully_strict.exp4:
hard_coded/exceptions/test_uncaught_exception.exp:
hard_coded/exceptions/test_uncaught_exception.exp2:
hard_coded/exceptions/test_uncaught_exception.exp3:
hard_coded/exceptions/test_uncaught_exception.exp4:
tabling/loopcheck.exp:
tabling/loopcheck.exp2:
tabling/loopcheck.exp3:
tabling/loopcheck.exp4:
	Changes now that we report that an Uncaught exception comes
	from Mercury.
2002-07-25 16:20:56 +00:00
Tyson Dowd
78fba023f6 Fix the expected test results to reflect the new implementation changes
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.
2001-08-30 12:54:01 +00:00
Peter Ross
96b1c9eb67 Changes required to the test cases for the new string__format.
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.
2000-08-11 08:24:04 +00:00
Fergus Henderson
3a65095708 Avoid hard-coding dependencies on line numbers
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.
2000-02-03 12:09:07 +00:00
Fergus Henderson
23330c766c Update the line numbers for io.m to reflect my recent change
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.)
1999-12-14 02:30:32 +00:00
Zoltan Somogyi
60238068ac Compile the files in the library directory with --trace minimum by default,
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.
1999-11-15 08:14:22 +00:00
Zoltan Somogyi
f4f9002fda Update the expected output of these tests cases when stack trace is
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.
1999-10-13 02:51:00 +00:00
Peter Ross
84b93e4a2b Update tests to reflect that error now throws an exception.
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:
1999-09-02 05:48:57 +00:00
Fergus Henderson
6accb8113d Fix some spurious test cases failures for the debugging test cases.
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).
1998-11-16 07:26:58 +00:00
Fergus Henderson
b8aed5707b Allow test cases to have more than one expected output.
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.
1998-11-04 07:53:29 +00:00