Commit Graph

66 Commits

Author SHA1 Message Date
Zoltan Somogyi
7b6bace9ec Don't return dummy parse_trees for missing files.
The predicates that read a Mercury source, interface or optimization file
used to return four things:

- the name of the file (for callers who specified only a module name),
- the timestamp, if requested and available,
- a parse tree, and
- a representation of any errors (sets of error categories, and error_specs).

However, these four things were not independent. Some combinations of their
values were not allowed, but (a) there was no documentation of what these
combinations were, and (b) code that processed these four things had to be
prepared to handle illegal as well as legal combinations.

This diff makes these predicates return only one result, which contains

- all four of the above things, when the file could be opened, but
- only the file name and a representation of the error if the file
  could not be opened,
- only the file name and a representation of *no* errors, if the caller
  asked the predicate to read the file only if its timestamp did not match
  a specified value, and it does match that value.

We use a somewhat modified version of an existing type, have_read_module,
for this. It is modified both by including information that its users
now need that they did not need before, and shortening the names of its
function symbols, which now occur in many more places than before.

compiler/read_modules.m:
    Make the change to the output arguments described above.

    Making this change requires having the affected predicates deal with
    the case where we either cannot find or cannot open the relevant file.
    (The two are effectively the same thing in this module, since we search
    by attempting to open.) Passing that task off to parse_modules.m
    was always inelegant.

    Simplify the have_read_module_map type by making the key always
    be a module_name. We deleted the only use of have_read_module_maps
    with another kind of key a while ago.

    Delete some no-longer-needed predicates.

compiler/parse_module.m:
    Delete the code dealing with the absence of a file stream to parse.

    Replace code that used to construct dummy parse trees with code
    that simply returns *no* parse tree if the file could be opened
    but could not be read, or if its timestamp indicated that reading it
    would have been redundant.

    Delete some utility predicates moved to parse_error.m, so that
    read_modules.m could also use them.

    Fix comment rot.

compiler/parse_error.m:
    Add some utility predicates for use by read_modules.m and parse_module.m.

compiler/deps_map.m:
    Conform to the changes above.

    Document the dubious effects of an old design decision.

    Fix a misleading predicate name.

    Fix comment rot.

compiler/grab_modules.m:
    Conform to the changes above.

    Some predicates used to return parse trees that could be dummies.
    Change them to return just the parts of the parse tree that the
    caller was interested in, which was usually a tiny part, and which
    can be constructed trivially even when we don't have a parse tree.

    Delete an unneeded type.

compiler/recompilation.check.m:
    Conform to the changes above.

    Represent the operations we need to test version numbers in interface files
    as a typeclass, and rewrite the checking operation in terms of that
    typeclass, with one instance for each kind of interface file.

    Move some repeated code into a predicate.

    Shorten some long names.

compiler/mercury_compile_main.m:
    Conform to the changes above.

    Break up a large predicate.

compiler/generate_dep_d_files.m:
compiler/make.module_dep_file.m:
compiler/write_module_interface_files.m:
    Conform to the changes above.

compiler/prog_item.m:
    Delete the parse_tree_some_int type. The change in recompilation.check.m,
    deleted its last few uses there, and allowed the deletion of the last
    uses in read_modules.m.

tests/recompilation/two_module_debug:
    Extend this script to help deal with problems in all stages of the
    execution of a test case, since that was required while debugging
    this diff.

    Document which parts of this script correspond to which parts of
    two_module_test.

tests/recompilation/test_functions:
tests/recompilation/two_module_test:
    Simplify the logic of the main test function, by testing a condition
    once instead of three times.

    Specify whether a recompilation test is expected to succeed or fail
    directly, using alternatives that model a bespoke type, instead
    of alternatives that mimic a boolean answer to a question, which
    does not help readers who don't remember the question.

    Always put shell variable names in braces.

    Note a problem that makes one of the shell functions ineffective.

tests/recompilation/Mmakefile:
    Tell two_module_test what to do using its updated interface.
2022-04-30 14:37:22 +10:00
Zoltan Somogyi
849228ecbb Update programming style in tests/recompilation. 2022-01-25 21:21:40 +11:00
Zoltan Somogyi
f12968eee6 Replace item_id_set with several specialized types.
The old code used item_id_sets for representing several closely related
but nevertheless significantly different pieces of information. These had
different invariants, but these could not be expressed in the type.
Using a different type for each purpose allows encoding the applicable
invariants in the types.

Also, the original code was organized around higher order code
that (a) used an item_type key to get a field from an item_id_set,
(b) did something with that field, and then, in some cases
(c) put its updated version back into the item_id_set.
It often did this in a loop over some, but not all, item_type values.
This diff replaces such code with code that (a) deconstructs a value
in one of item_id_set's replacement types, (b) uses a separate call
to process each field that needs to be processed, and then maybe
(c) constructs a new value containing the updated field.

This new approach has several advantages.

- It is more direct and hence more understandable. Due to the extra code
  that used to be required by the higher order machinery, it can also be
  shorter.

- It made clear that two of the fields of item_id_set, the fields
  ostensibly containing information about mutables and foreign_procs,
  were *never actually used*.

- It also works when the fields are not all the same type. The old code
  stored information about instances separately from item_id_sets
  precisely because it would have required a field of a different type.

- This last point allows a future diff to further specialize the types
  of the fields. Some now store items; in the future, they could store
  either just one specific kind of item, or one of a small set of kinds
  of items; e.g. the fields for predicates and functions could store
  one of item_pred_decl_infos, item_mode_decl_infos or item_decl_pragma_infos.

- It is also more efficient. Some of the old traversals allocated a new
  item_id_set every time they updated a field, with their replacement
  traversals never constructing a new item_id_set (or rather a value
  of one of its replacement types) until the traversal is complete.

One minor aspect of the change is that this diff consistently puts insts
before modes in data structures and in the code that operates on them,
as we do in the rest of the compiler. Another is that it uses the name_arity
type to replace the type that the old code used, which was pair(string, int).

compiler/recompilation.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
    As above.

    Delete assignments to !:MaybeStoppingReason that assign it the value
    ("no") that !.MaybeStoppingReason already contains, as tested
    immediately above.

    Add XXX RECOMP where further changes are desirable.

compiler/module_qual.id_set.m:
    Put insts before modes in id_type.

library/cord.m:
    Add foldl versions with two and three accumulators.

NEWS:
    Announce the new predicates.

tests/recompilation/two_module_debug:
    Add this script, which can help debug problems with smart recompilation.

tests/recompilation/Mercury.options:
    Fix indentation.
2021-08-27 21:49:37 +10:00
Zoltan Somogyi
f6c829fe57 Expect an updated line number. 2021-07-30 00:29:29 +10:00
Zoltan Somogyi
11bdb872de Simplify some code. 2021-07-29 22:28:11 +10:00
Zoltan Somogyi
52208fc8bf Use the new type maybe_top_module.
compiler/module_imports.m:
    The module_and_imports structure used to have a field, mf_nested_children,
    which stored a set of module names, but which had confusing semantics:
    it had two different meanings in two different circumstances.
    Replace that field with a value of a new type, maybe_top_module, which
    has two separate function symbols for those two circumstances:
    when a module is the top module in its source file, and when it is not.

compiler/mercury_compile_main.m:
    Conform to the change above.

    Put related arguments next to each other.

compiler/grab_modules.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/recompilation.check.m:
compiler/write_deps_file.m:
    Conform to the change above.

tests/recompilation/test_functions:
    Impose a limit of 10 minutes of CPU time on each process. This should
    help catch infinite loops, such as happened during the development
    of this diff.

    Fix indentation, and clarify some comments.

tests/recompilation/README:
    Fix stray blank line.
2021-07-19 20:48:12 +10:00
Zoltan Somogyi
1f45f91886 Make "mmake runtests" work again.
My commit afe2887882 broke the ability
to run the test suite outside of a bootcheck by executing "mmake runtests"
in the tests directory. This diff fixes that.

tests/Mmake.common:
    Don't define "TESTS_DIR = ..". While every single tests/*/Mmakefile
    defined it as such, I overlooked the fact that tests/Mmakefile itself
    defined it ".", referring to the same directory from a different starting
    point. Document this easily-overlooked fact.

    Rename the old runtests target, which after afe2887 runs the tests
    in a single directory, as runtests_dir, to leave the target name
    "runtests" itself free for tests/Mmakefile to use.

tests/Mmakefile:
    Define "TESTS_DIR = .", and add a target "runtests" which invokes
    "mmake runtests_dir" in each test directory.

tools/bootcheck:
    Invoke "mmake runtests_dir" instead of "mmake runtests" in each
    test directory.

    Initialize a variable just before it is used.

tests/*/Mmakefile:
    Add back the definition "TESTS_DIR = .."
2020-06-10 01:05:15 +10:00
Zoltan Somogyi
afe2887882 Remove stale references to test subdirs.
A long time ago, test directories such as hard_coded had subdirectories
such as hard_coded/typeclasses. These have since been flattened out
(e.g. hard_coded/typeclasses is now just typeclasses), but there were
still remnants of the old approach. This diff deletes those remnants.

tests/*/Mmakefile:
    Delete the TESTS_DIR and the SUBDIRS mmake variables; TESTS_DIR
    was always set to "..", and SUBDIRS to the empty string.

    Delete any references to the make variable NOT_WORKING, since
    it is never used.

tests/Mmake.common:
    Document that Mmakefiles in test directories don't have to set
    TESTS_DIR and SUBDIRS anymore. Fix the formatting of the documentation
    of the make variables they do still have to set.

    Delete the targets and actions for handling subdirectories of
    test directories, since there aren't any.

tests/Mmakefile:
    Simplify some code.
2020-04-14 11:23:12 +10:00
Zoltan Somogyi
1b093f34ee Stop using a type where it does not belong.
compiler/module_imports.m:
    The module_timestamp type has long had a field of the need_qualifier type.
    For a year or more now, this field has had a big comment on it explaining
    why its use here does not match the semantics of the need_qualifier type.

    This diff gives this field a new, bespoke type, that is isomorphic
    to need_qualifier, but is completely deparate. Document the reason why
    I *can't* document the semantics of this new type :-(

compiler/grab_modules.m:
    Do the same kind of replacement on values that are used only to set
    this field of module_timestamps.

compiler/recompilation.check.m:
compiler/recompilation.usage.m:
    Use the values of the new type to make the same decisions we used to make
    using values of the need_qualifier type.

tests/recompilation/*.m*:
    Bring the programming style of these modules up to date.

tests/recompilation/*.err_exp.2:
    Expect the updated line numbers in messages.

Delete the need_qualifier field from timestamps.
2019-11-09 17:53:43 +11:00
Zoltan Somogyi
7b82c59c40 Remove unneeded module qualifications from error messages.
This should make error messages easier to read by removing clutter.

compiler/error_util.m:
    Split each of the sym_name and sym_name_and_arity error pieces into two;
    one which prints any module qualification present in the given sym_name,
    and one which does not. This forces people who use these pieces
    to think about whether they want the sym_name module qualified
    in the error message or not.

compiler/add_class.m:
compiler/add_clause.m:
compiler/add_foreign_enum.m:
compiler/add_foreign_proc.m:
compiler/add_mode.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/check_for_missing_type_defns.m:
compiler/check_promise.m:
compiler/check_raw_comp_unit.m:
compiler/check_typeclass.m:
compiler/det_report.m:
compiler/equiv_type.m:
compiler/format_call.m:
compiler/hlds_error_util.m:
compiler/inst_check.m:
compiler/introduce_parallelism.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/make_tags.m:
compiler/mercury_compile_main.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/modules.m:
compiler/oisu_check.m:
compiler/parse_inst_mode_defn.m:
compiler/parse_item.m:
compiler/parse_module.m:
compiler/parse_pragma.m:
compiler/parse_type_defn.m:
compiler/polymorphism.m:
compiler/post_term_analysis.m:
compiler/prog_out.m:
compiler/recompilation.check.m:
compiler/resolve_unify_functor.m:
compiler/split_parse_tree_src.m:
compiler/type_constraints.m:
compiler/typecheck_errors.m:
compiler/unused_args.m:
compiler/unused_imports.m:
    Conform to the change above. For sym_name references for which
    the module qualifier is obvious (usually because it *has* to be
    the module being compiled), change the reference to the variant
    that omits that qualifier; otherwise, keep the qualifier.

    In a few places, improve the wording of an error message.

tests/invalid/bad_instance.err_exp:
tests/invalid/bug17.err_exp:
tests/invalid/builtin_int.err_exp:
tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/foreign_type_visibility.err_exp:
tests/invalid/fp_dup_bug.err_exp:
tests/invalid/fundeps_vars.err_exp:
tests/invalid/impl_def_literal_syntax.err_exp:
tests/invalid/inline_conflict.err_exp:
tests/invalid/inst_list_dup.err_exp:
tests/invalid/instance_no_type.err_exp:
tests/invalid/invalid_typeclass.err_exp:
tests/invalid/missing_interface_import.err_exp:
tests/invalid/missing_interface_import2.err_exp:
tests/invalid/oisu_check_semantic_errors.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/tc_err2.err_exp:
tests/invalid/transitive_import.err_exp:
tests/invalid/type_with_no_defn.err_exp:
tests/invalid/typeclass_bogus_method.err_exp:
tests/invalid/typeclass_missing_mode_2.err_exp:
tests/invalid/typeclass_test_10.err_exp:
tests/invalid/typeclass_test_3.err_exp:
tests/invalid/typeclass_test_4.err_exp:
tests/invalid/typeclass_test_5.err_exp:
tests/invalid/typeclass_test_9.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/undef_inst.err_exp:
tests/invalid/undef_mode.err_exp:
tests/invalid/undef_mode_and_no_clauses.err_exp:
tests/invalid/undef_type.err_exp:
tests/invalid/undef_type_mod_qual.err_exp:
tests/invalid/uu_type.err_exp:
tests/invalid/where_direct_arg.err_exp:
tests/invalid/where_direct_arg2.err_exp:
tests/invalid/wrong_type_arity.err_exp:
tests/recompilation/add_type_re.err_exp.2:
tests/recompilation/field_r.err_exp.2:
tests/recompilation/remove_type_re.err_exp.2:
tests/warnings/inst_with_no_type.exp:
    Expect the updated versions of error messages.
2017-04-01 20:20:57 +11:00
Zoltan Somogyi
589e8c9faf Improve an error message. 2016-02-14 00:28:03 +11:00
Zoltan Somogyi
a0760327b6 Do stricter checking of mode and determinism declarations.
Specifically, we now do three new checks:

BAD_DETISM: We now generate error messages for predicate declarations
that specify a determinism without also specifying argument modes.

BAD_PREDMODE: We now generate error messages for standalone mode declarations
for predicates whose predicate declaration includes modes for the arguments.

BAD_MODE_SECTION: We now generate error messages for standalone mode
declarations that are not in the same section as the predicate's (or
function's) type declaration.

compiler/hlds_pred.m:
    Add a slot to the pred_sub_info. If the predicate is explicitly defined by
    the user in the current module, this contains the id of the section that
    contains its predicate declaration (for the BAD_MODE_SECTION check)
    and whether that predicate declaration also had modes for the arguments
    (for the BAD_PREDMODE check).

compiler/add_pred.m:
    When adding adding new predicate declarations, perform the BAD_DETISM
    check, and record the info needed for the BAD_PREDMODE and BAD_MODE_SECTION
    checks.

    When adding adding new mode declarations, perform the BAD_PREDMODE
    and BAD_MODE_SECTION checks.

compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/dep_par_conj.m:
compiler/higher_order.m:
compiler/make_hlds_passes.m:
compiler/table_gen.m:
compiler/unused_args.m:
    Conform to the changes above.

mdbcomp/builtin_modules.m:
    Add a utility predicate for use by new code in add_pred.m.

compiler/comp_unit_interface.m:
compiler/goal_util.m:
compiler/prog_rename.m:
compiler/quantification.m:
deep_profiler/program_representation_utils.m:
library/calendar.m:
library/mutvar.m:
library/pretty_printer.m:
library/random.m:
library/set_ctree234.m:
library/solutions.m:
library/stream.string_writer.m:
profiler/globals.m:
tests/accumulator/nonrec.m:
tests/accumulator/out_to_in.m:
tests/declarative_debugging/library_forwarding.m:
tests/dppd/applast_impl.m:
tests/dppd/grammar_impl.m:
tests/dppd/regexp.m:
tests/dppd/transpose_impl.m:
tests/hard_coded/copy_pred.m:
tests/hard_coded/ho_func_default_inst.m:
tests/recompilation/unchanged_pred_nr_2.m.1:
tests/recompilation/unchanged_pred_nr_2.m.2:
tests/valid/det_switch.m:
tests/valid/inlining_bug.m:
    Delete determinism declarations from predicate and function declarations
    that have no argument mode information, since the BAD_DETISM check
    now makes these errors.

tests/valid/two_pragma_c_codes.m:
    Move some mode declarations to the right section, since the
    BAD_MODE_SECTION check now generates an error for the old code.

tests/invalid/typeclass_bad_method_mode.{m,err_exp}:
    New test case to test for the BAD_PREDMODE check.

tests/invalid/mode_decl_in_wrong_section.{m,err_exp}:
    New test case to test for the BAD_MODE_SECTION check.

tests/invalid/bad_detism.err_exp:
    Add an expected output for this old, but never enabled test case,
    which tests for new check BAD_DETISM.

tests/invalid/Mmakefile:
    Enable the new test cases.

tests/invalid/typeclass_dup_method_mode.m:
    This test case used to have two bugs. One is now by itself in the new
    typeclass_bad_method_mode.m test case, so modify it to contain only
    the other (indistinguishable modes).

tests/invalid/func_errors.err_exp:
tests/invalid/tc_err1.err_exp:
tests/invalid/undef_lambda_mode.err_exp:
tests/invalid/undef_type_mode_qual.err_exp:
    Expect an extra error message from the BAD_DETISM check.
2016-01-13 02:03:16 +11:00
Zoltan Somogyi
0821b301f2 Require that types/insts/modes in interfaces be defined in the interface.
compiler/module_qual.m:
    The interface of a module A contains items (e.g. predicate declarations)
    that refer to entities such as types, insts, modes etc. They may refer
    to those entities if (a) they are defined in the interface of module A,
    (b) in a parent module of module A, or (c) if they are imported from
    another module, module B, which is imported into module A in the interface
    of module A.

    The old algorithm that attempted to enforce this requirement had a basic
    design fault: it based the decision as to whether the use of an entity
    in the interface was legal solely on the name of the module that defined
    that entity. This correctly implements tests (b) and (c), but it does
    not even attempt to implement the interface test part of (a).
    It therefore allowed exported items to refer to nonexported entities.

    This diff changes the whole design approach to the test. Instead of
    keeping a list of modules *all* of whose entities may be used in the
    interface of the current module, record for *every* entity whether
    it may be used in the interface. Set the permissions differently
    in the interface and implementation sections of the current module.

    Improve the formatting of the ambiguity error message.

NEWS:
    Announce the stricter enforcement of the documented language rules,
    in a new section for potentially compatibility-breaking changes.

compiler/check_typeclass.m:
    Delete a test for a special case of the situation that module_qual.m
    now tests for. If this problem occurs, module_qual.m will pick it up,
    and check_typeclass.m will never even be invoked, so this copy of the test
    can never succeed.

library/hash_table.m:
    Fix code that violated the language rules: we export a type that
    includes another type, but didn't export the second type. We now do.

browser/declarative_analyser.m:
browser/declarative_edt.m:
compiler/coverage_profiling.m:
    Fix code that violated the language rules. We used to export predicates
    and functions whose argument types included nonexported types. As it
    happens, none of those predicates and functions actually need to be
    exported, so keep them private.

    In coverage_profiling.m, don't abstract export a type that is not
    used outside the module, and give a function a name that doesn't
    clash with a type name.

tests/invalid/bug17.{m,err_exp}:
    A new test case to test the error message we get if the module interface
    refers to a nonexported type.

tests/invalid/bad_instance.err_exp:
    This test case used to get two kinds of errors, one of which was
    the illegal use of nonexported type in an exported abstract instance
    declaration. We now discover this error earlier, and stop after we
    do so. Update the expected error message.

tests/invalid/bad_instance2.{m,err_exp}:
    New test case: a modified copy of bad_instance.m, testing the other
    kind of error originally tested by bad_instance.m.

tests/invalid/instance_no_type.err_exp:
    Update the expected error message.

tests/invalid/Mmakefile:
    Enable the new test cases.

tests/benchmarks/query.m:
tests/hard_coded/unused_float_box_test.m:
tests/valid/bug300.m:
tests/valid/deforest_bug.m:
tests/valid/higher_order4.m:
tests/valid/lambda_recompute.m:
tests/valid/mert.m:
tests/valid/reuse_static.m:
tests/valid/switch_detection_bug2.m:
tests/valid/time_yaowl.m:
tests/warnings/unused_args_test.m:
    Fix code that violated the language rules, typically by exporting
    the type that previously, we illegally used in the module interface.

tests/recompilation/add_type_re.err_exp.2:
    Expect the updated ambiguity error message.
2015-11-11 14:28:57 +11:00
Zoltan Somogyi
8a764392d9 Avoid warnings from make in test directories.
tests/Mmake.common:
    Don't invoke any actions in the clean_local and realclean_local
    targets, since if using mmc --make, the builtin mmake rules
    have actions for those targets as well, and make can't handle
    more than one action for a target having actions. Replace those
    actions with dependencies on other, unique targets that have
    the actions instead.

tests/*/Mmakefile:
    Avoid actions in clean_local and realclean_local targets the same way.

    Sort the test names in some directories that didn't already do so.

    Delete some obsolete comments.

    Fix style.

tests/valid/Mmake.valid.common:
    As for the Mmakefiles above, and also move the definition of a make
    variable before it is needed.
2015-09-08 05:57:53 +10:00
Zoltan Somogyi
693d1f5512 Update the style of recompilation test scripts.
tests/recompilation/test_functions:
tests/recompilation/two_module_test:
    Update these shell scripts to our current coding style.
2015-07-11 13:39:06 +02:00
Zoltan Somogyi
73f0a36719 Allow the use of -jN in many test directories.
tests/Mmake.common:
    Replace the -j1 in the runtests_local target used by all the test
    directories with $(MAYBE_J1).

tests/*/Mmakefile:
    Define MAYBE_J1 it as the empty string in test directories in which
    different tests don't share source files.

    Define MAYBE_J1 as -j1 in test directories in which
    different tests do share source files.

tests/submodules/sub2_a.m:
    Add this copy of sub_a.m to allow tests in the submodules directory
    to be done in parallel.

tests/submodules/accessibility2.m:
    Import sub2_a.m instead of sub_a.m.

tests/warnings/ambig_types_high_level.m:
    Add this copy of ambig_types.m to allow tests in the warnings directory
    to be done in parallel.

tests/warnings/ambig_high_level.m:
    Import ambig_types_high_level.m instead of ambig_types.m.
2015-02-19 06:02:45 +11:00
Zoltan Somogyi
fdd141bf77 Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the tests
    that check compiler error messages, expect the new line numbers.

browser/cterm.m:
browser/tree234_cc.m:
    Import only one module per line.

tests/hard_coded/boyer.m:
    Fix something I missed.
2015-02-16 12:32:18 +11:00
Zoltan Somogyi
d33273d033 Tell vim not to expand tabs in Makefiles.
This file-specific setting will override a default setting of expandtabs
in $HOME/.vimrc.

*/Makefile:
*/Mmakefile:
    As above.

tests/hard_coded/.gitignore:
    Don't ignore the purity subdir. This ignore must have been left over
    from when purity.m was a test in hard_coded, not hard_coded/purity,
    and it ignored an executable, not a directory.
2015-01-08 22:07:29 +11:00
Zoltan Somogyi
11f2a2e9ee Print better contexts for module qualification errors.
Specifically, when we find undefined types in type definitions, say WHERE
the undefined type is (both as line number and as function symbol/arg number,
and field name if present), since the body of the type definition is sometimes
quite big.

compiler/module_qual.m:
    When module qualification found an error, it used to get the context
    it printed for the error from the mq_info structure, which also contained
    the rest of the state of the qualification process. The drawback of this
    setup is that the mq_info's record of the error context was updated
    only in a few of the places where that context actually changed.

    This diff takes the error context out of the mq_info, and passes it
    as a separate argument to the predicates that need it. This makes it
    really visible if a context is passed onward unchanged even when it
    should be updated.

    Fix some of these places, and mark the rest with XXXs.

    When printing error messages about predicate or function declarations,
    the message talked about definitions, not declarations. Fix that.

    Put a prog_context inside each function symbol of mq_error_context;
    don't require the creation of a separate memory cell for a pair
    to link the mq_error_context with the prog_context.

    Factor out some common code.

compiler/prog_data.m:
    I tried to put a context inside constraints for use in error contexts
    in module_qual.m, but that turned out to be a bad idea. Document why.

compiler/add_class.m:
compiler/equiv_type.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/hlds_data.m:
compiler/post_typecheck.m:
compiler/pred_table.m:
compiler/prog_io_typeclass.m:
compiler/prog_type.m:
compiler/recompilation.usage.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
compiler/typecheck.m:
compiler/typeclasses.m:
compiler/unused_imports.m:
compiler/write_module_interface_files.m:
compiler/xml_documentation.m:
    Clean up some code dealing with constraints. I did this cleanup while
    adding contexts to constraints, a change I then had to undo.

tests/invalid/builtin_int.err_exp:
tests/invalid/errors.err_exp:
tests/invalid/errors1.err_exp:
tests/invalid/fundeps_vars.err_exp:
tests/invalid/missing_interface_import.err_exp:
tests/invalid/missing_interface_import2.err_exp:
tests/invalid/test_nested.err_exp:
tests/invalid/transitive_import.err_exp:
tests/invalid/undef_type.err_exp:
tests/invalid/undef_type_mod_qual.err_exp:
tests/recompilation/add_type_re.err_exp.2:
tests/recompilation/remove_type_re.err_exp.2:
    Update these expected output files to match the better messages
    we now generate.
2015-01-01 15:19:56 +11:00
Julien Fischer
b635ebf80b Convert .cvsignore -> .gitignore files in tests directory.
tests/*/.cvsignore:
    As above.

library/.gitignore:
    Ignore files generated by the namespace cleanliness check.
2013-01-07 14:33:25 +11:00
Julien Fischer
a60beb42e7 Make the none.gc.memprof grade work with MSVC again.
Branches: main, 11.07

Make the none.gc.memprof grade work with MSVC again.

Avoid more warnings when compiling with MSVC.

compiler/layout_out.m:
	Avoid an incomplete type in the declaration of the alloc_sites
	array.  (Similar changes need to be made for the layout structures
	related to debugging and deep profiling - I am in the process of
	testing the former, the latter doesn't currently work on Windows
	any way.)

browser/listing.m:
	Use don't-care variables in some foreign_procs.
	This avoids warnings about assignments from uninitialized
	variables with MSVC.

*/.cvsignore:
	Update cvsignore entries.

	Ignore files generated by mprof.
2011-10-20 06:37:35 +00:00
Peter Wang
75771a9b6e Allow testing of java grade. Requires using `mmc --make' for now.
Branches: main

Allow testing of java grade.  Requires using `mmc --make' for now.
This patch does not attempt to fix test failures.

tests/Mmake.common:
        Delete unneeded Java-specific rule, which was broken.

tests/benchmarks/Mmakefile:
tests/general/Mmakefile:
tests/general/string_format/Mmakefile:
tests/grade_subdirs/Mmakefile:
tests/hard_coded/Mmakefile:
tests/recompilation/Mmakefile:
tests/term/Mmakefile:
tests/valid/Mmakefile:
        Don't deliberately disable tests in java grade.

tests/*.m:
        Add Java foreign code.

        Write dummy procedures instead of abusing `:- external'.
2009-08-14 03:21:55 +00:00
Zoltan Somogyi
dcd2922eb4 Sort the lists of tests in each directory. (We usually keep each list
Estimated hours taken: 0.2
Branches: main

tests/*/Mmakefile:
	Sort the lists of tests in each directory. (We usually keep each list
	sorted, but then we concatenate several lists, which loses the order.)
	This gives you a better idea of how far a bootcheck still has to go.

tools/bootcheck:
	Build the interface files before the rest of the files in the library
	directory. Again, this gives you a better idea of how far a bootcheck
	still has to go.

	Make the dependencies for the slice subdirectory of the stage2 at the
	same time as the other subdirs; don't let it be caught later.

library/Mmakefile:
	Build the interface files in the right order.
2008-12-01 00:32:58 +00:00
Julien Fischer
a47cd0762e Ignore *.err files and .mgnuc* files.
tests/recompilation/.cvsignore:
	Ignore *.err files and .mgnuc* files.
2007-07-23 02:10:57 +00:00
Peter Wang
40a21f2d78 Implement some more I/O primitives for Erlang.
Estimated hours taken: 1.5
Branches: main

library/io.m:
	Implement some more I/O primitives for Erlang.

tests/debugger/Mmakefile:
tests/debugger/declarative/Mmakefile:
tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
tests/par_conj/Mmakefile:
tests/recompilation/Mmakefile:
tests/valid/Mmakefile:
	Disable test cases which don't apply to the Erlang backend for
	whatever reason.

tests/hard_coded/constraint_order.m:
tests/hard_coded/copy_pred.m:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/export_test.m:
tests/hard_coded/external_unification_pred.m:
tests/hard_coded/foreign_type3.m:
tests/hard_coded/ho_solns.m:
tests/hard_coded/ho_univ_to_type.m:
tests/hard_coded/intermod_multimode.m:
tests/hard_coded/intermod_poly_mode_2.m:
tests/hard_coded/lookup_disj.m:
tests/hard_coded/multimode.m:
tests/hard_coded/no_inline.m:
tests/hard_coded/pragma_foreign_export.m:
tests/hard_coded/redoip_clobber.m:
tests/hard_coded/rnd.m:
tests/hard_coded/sub-modules/sm_exp_bug.m:
tests/hard_coded/typeclasses/impure_methods.m:
tests/par_conj/dep_par_10.m:
tests/valid/flatten_conj_bug.m:
	Fix test cases which were failing with the Erlang for simple reasons,
	mostly missing foreign procs or foreign types.

tests/general/string_format_test_2.exp5:
tests/general/string_format_test_3.exp5:
tests/hard_coded/exceptions/test_uncaught_exception.exp5:
tests/hard_coded/no_fully_strict.exp5:
	Add expected outputs with stack dumps for Erlang.
2007-06-06 01:48:15 +00:00
Ralph Becket
427c7518ec Improve the readability of float output from the debugger and io.print etc.
Estimated hours taken: 4
Branches: main

Improve the readability of float output from the debugger and io.print etc.
by pruning redundant trailing zeroes.

NEWS:
	Mention the change.

library/string.m:
runtime/mercury_float.c:
	Make string.float_to_string trim redundant trailing zeroes.
	The behaviour of string.format etc. is unchanged.

tests/debugger/ambiguity.exp:
tests/debugger/field_names.exp:
tests/debugger/higher_order.exp:
tests/debugger/print_table.exp:
tests/hard_coded/common_type_cast.exp:
tests/hard_coded/constant_prop_1.exp:
tests/hard_coded/construct_test.exp:
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deep_copy.exp:
tests/hard_coded/deep_copy_exist.exp:
tests/hard_coded/dense_lookup_switch2.exp:
tests/hard_coded/dense_lookup_switch_non.exp:
tests/hard_coded/existential_float.exp:
tests/hard_coded/expand.exp:
tests/hard_coded/final_excp.exp:
tests/hard_coded/float_field.exp:
tests/hard_coded/float_gv.exp:
tests/hard_coded/float_reg.exp:
tests/hard_coded/float_rounding_bug.exp:
tests/hard_coded/init_excp.exp:
tests/hard_coded/mutable_excp.exp:
tests/hard_coded/pragma_import.exp:
tests/hard_coded/prince_frameopt.exp:
tests/hard_coded/string_string.exp:
tests/hard_coded/unused_float_box_test.exp:
tests/hard_coded/write.exp:
tests/hard_coded/write_binary.exp:
tests/hard_coded/write_reg1.exp:
tests/hard_coded/write_xml.exp:
tests/hard_coded/sub-modules/non_word_mutable.exp:
tests/hard_coded/typeclasses/arbitrary_constraint_class.exp:
tests/hard_coded/typeclasses/arbitrary_constraint_pred_1.exp:
tests/hard_coded/typeclasses/arbitrary_constraint_pred_2.exp:
tests/hard_coded/typeclasses/existential_rtti.exp:
tests/hard_coded/typeclasses/func_default_mode_bug.exp:
tests/hard_coded/typeclasses/mode_decl_order_bug.exp:
tests/hard_coded/typeclasses/module_test.exp:
tests/hard_coded/typeclasses/typeclass_exist_method.exp:
tests/invalid/error_in_list.err_exp:
tests/invalid/errors2.err_exp:
tests/invalid/purity/purity_type_error.err_exp:
tests/mmc_make/complex_test.exp:
tests/recompilation/add_type_re.exp.1:
tests/recompilation/type_spec_rename_var_r.exp.1:
tests/recompilation/type_spec_rename_var_r.exp.2:
tests/recompilation/type_spec_unname_var_r.exp.1:
tests/recompilation/type_spec_unname_var_r.exp.2:
	Updated expected test case output.
2007-02-15 00:41:59 +00:00
Zoltan Somogyi
5eee81204e A big step towards cleaning up the way we handle errors.
Estimated hours taken: 28
Branches: main

A big step towards cleaning up the way we handle errors. The main changes are

- the provision, in error_util.m, of a mechanism for completely specifying
  everything to do with a single error in one data structure,

- the conversion of typecheck_errors.m from using io.write_string to
  using this new capability,

- the conversion of mode_errors.m and det_report.m from using
  write_error_pieces to using this new capability, and

- consistently using the quoting style `symname'/N instead of `symname/N'
  in error_util and hlds_error_util (previously, error_util used the former
  but hlds_error_util used the latter).

This diff sets up later diffs which will collect all error specifications
in a central place and print them all at once, in order.

compiler/error_util.m:
	The new type error_spec, which completely specifies an error.
	An error_spec may have multiple components with different contexts
	and may have parts which are printed only under certain conditions,
	e.g. a given option being set. Each error_spec has a severity
	and also records which phase found the error.

	The new predicate write_error_spec takes care of updates of the exit
	status for errors and (if --halt-at-warn is set) for warnings. It also
	takes care of setting the flag that calls for the reminder about -E
	at the end.

	This diff also makes it simpler to use the ability to print arbitrary
	output. It adds the ability to include integers in messages directly,
	and the ability to create blank lines. It renames some function symbols
	to avoid ambiguities.

	Move a predicate that only used by typecheck_errors.m to that file.

compiler/hlds_error_util.m:
	Switch to the `symname'/N quoting style for describing predicates and
	procedures.

compiler/prog_util.m:
	Switch to the `symname'/N quoting style for describing
	sym_name_and_arity.

compiler/hlds_module.m:
	Provide a predicate to increment the number of errors not by one,
	but by the number of errors printed by write_error_spec.

	Fix some documentation rot.

compiler/typecheck_errors.m:
	Use write_error_spec instead of io.write_strings to print error
	messages. In several cases, improve the formatting of the messages
	printed.

	Mark a number of places where we don't (yet) update the number of
	errors in the module_info correctly.

	Rename the checkpoint predicate to avoid potential ambiguity with
	similar predicates in e.g. mode_info.

compiler/typecheck_info.m:
	Group the code for writing stuff out together in one bunch. For each
	such predicate, create another that returns a list of format components
	instead of doing I/O directly.

compiler/typecheck.m:
	Move the code for writing inference messages here from
	typecheck_errors.m, since these messages aren't errors.

compiler/mode_errors.m:
compiler/det_report.m:
	Use write_error_spec instead of write_error_pieces. In the case of
	mode_errors.m, this means we now get correct the set of circumstances
	in which we set the flag that calls for the reminder about -E.

compiler/add_pragma.m:
compiler/add_type.m:
	Convert some code that used to use write_error_pieces to print error
	messages to use write_error_spec instead.

compiler/assertion.m:
compiler/hlds_pred.m:
compiler/post_typecheck.m:
	Assertion.m used to contain some code to check for assertions in the
	interface that mention predicates that are not exported. Move most
	of this code to post_typecheck.m (which is where this code used to be
	called from). One small part, which is a test for a particular property
	of import_statuses, is moved to hlds_pred.m to be with all the other
	similar tests of import_statuses.

compiler/prog_util.m:
	Change unqualify_name from a predicate to a function.

compiler/pred_table.m:
compiler/hlds_out.m:
	Avoid some ambiguities by adding a suffix to the names of some
	predicates.

compiler/*.m:
	Conform to the changes above.

library/list.m:
	Add a function that was previously present (with different names)
	in two compiler modules.

tests/hard_coded/allow_stubs.exp:
	Update the format of the expected exception.

tests/invalid/errors2.err_exp2:
	Remove this file. As far as I can tell, it was never the correct
	expected output on the main branch. (It originated on the alias branch
	way back in the mists of time.)

tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/warnings/*.exp:
	Update the format of the expected error messages.

tests/recompilation/*.err_exp.2:
	Update the format of the expected messages about what was modified.
2006-09-07 05:51:48 +00:00
Julien Fischer
835d8315ef Do not allow discriminated unions with a single zero-arity constructor to have
Estimated hours taken: 10
Branches: main, release

Do not allow discriminated unions with a single zero-arity constructor to have
user-defined equality or comparison.  Defining such types causes an assertion
failure in the compiler because the types are considered to be dummy types and
the runtime currently doesn't support (and probably won't ever) d.u. dummy
types with user-defined equality or comparison.

Fix another bug where the compiler was not printing out the `recompile with
-E' prompt at the appropriate time.  The bug was caused by the fact that there
were several copies of the globals structure and the one that was being
checked at the time the prompt was being printed out was not the one that had
been updated during the rest of compilation.

compiler/add_types.m:
	Emit an error message if an attempt is made to define a d.u.  dummy
	type with user-defined equality or comparison.

compiler/globals.m:
	Remove the extra_error_info field from the globals structure and turn
	it into a mutable.  Export access predicates for this mutable.  The
	reason for doing this is that the compiler was sometimes looking at
	the wrong copy of the globals structure when checking the value of
	this flag - this meant that sometimes the recompile with `-E' prompt
	was not being displayed.  Turning this flag into a mutable avoids the
	problem because now there is only one copy.

compiler/make_hlds.m:
	s/__/./  in a few spots.

doc/reference_manual.texi:
	Mention the new restrictions on discriminated union types with
	user-defined equality or comparison.

tests/invalid/exported_unify2.m:
tests/invalid/exported_unify3.m:
	Change some types with user-defined equality or comparison so that
	they are no longer dummy types.  These test cases have not been
	triggering the assertion failure in the compiler because they are only
	error checked and the assertion that is failing occurs further along
	in the compilation process.

tests/invalid/user_eq_dummy.{m,err_exp}:
	Test the new error message for dummy types with user-defined equality
	or comparison.

tests/invalid/extra_info_prompt.{m,err_exp}:
	Test that the recompile with `-E' prompt is being displayed when it
	should.

tests/invalid/Mercury.options:
tests/invalid/Mmakefile:
	Include the new test cases.

	Where there is a verbose version of the error message compile with
	`-E'.

tests/recompilation/add_type_re.err_exp.2:
tests/invalid/*.err_exp:
	Update expected outputs to conform to the above.
2006-06-14 08:15:01 +00:00
Zoltan Somogyi
46a67b0b48 When the typechecker finds highly ambiguous overloading, print what symbols
Estimated hours taken: 16
Branches: main

When the typechecker finds highly ambiguous overloading, print what symbols
were overloaded, and where they occurred. Without this information, it is
very hard to fix the error if the predicate body is at all large.

Fix some software engineering problems encountered during this process.
Modify some predicates in error_util in order to simplify their typical usage.
Change the type_ctor type to be not simply a sym_name - int pair but a type
with its own identifying type constructor. Change several other types that
were also sym_name - int pairs (mode_id, inst_id, item_name, module_qual.id
and the related simple_call_id) to have their own function symbols too.

compiler/typecheck_info.m:
	Add a field to the typecheck_info structure that records the overloaded
	symbols encountered.

compiler/typecheck.m:
	When processing ambiguous predicate and function symbols, record this
	fact in the typecheck_info.

	Add a field to the cons_type_info structure to make this possible.

compiler/typecheck_errors.m:
	When printing the message about highly ambiguous overloading,
	what the overloaded symbols were and where they occurred.

compiler/error_util.m:
	Make error_msg_specs usable with plain in and out modes by separating
	out the capability requiring special modes (storing a higher order
	value in a function symbol) into its own, rarely used type.

	Make component_list_to_line_pieces a bit more flexible.

compiler/prog_data.m:
compiler/module_qual.m:
compiler/recompilation.m:
	Change the types listed above from being equivalence types (pairs)
	to being proper discriminated union types.

compiler/*.m:
	Conform to the changes above.

	In some cases, simplify the code's use of error_util.

tests/warnings/ambiguous_overloading.{m,exp}:
	Greatly extend this test case to test the new functionality.

tests/recompilation/*.err_exp.2
	Reflect the fact that the expected messages now use the standard
	error_util way of quoting sym_name/arity pairs.
2006-04-20 05:37:13 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Zoltan Somogyi
ef55b420fd Remove from std_util.m the predicates that merely call predicates in
Estimated hours taken: 12
Branches: main

Remove from std_util.m the predicates that merely call predicates in
the type_desc, construct and deconstruct modules, to reduce clutter
in std_util.m.

library/std_util.m:
	Remove those predicates from std_util.m.

library/deconstruct.m:
	Add a type we need that was previously defined in std_util.m.

library/construct.m:
	Delete some module qualifications that have now become unnecessary,

browser/browse.m:
browser/browser_info.m:
browser/declarative_tree.m:
browser/dl.m:
browser/help.m:
browser/sized_pretty.m:
browser/term_rep.m:
compiler/bytecode_gen.m:
compiler/llds_out.m:
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
library/assoc_list.m:
library/hash_table.m:
library/io.m:
library/pprint.m:
library/private_builtin.m:
library/prolog.m:
library/require.m:
library/rtti_implementation.m:
library/store.m:
library/term.m:
library/term_to_xml.m:
library/version_hash_table.m:
mdbcomp/program_representation.m:
	Import type_desc.m, construct.m and/or deconstruct.m to provide
	definitions of functions or predicates that up till now were in
	std_util.m. Modify the calls if the called function or predicate
	had a slightly different interface in std_util.m.

	Also, convert term_to_xml.m to four-space indentation, and delete
	unnecessary module qualifications in term.m.

tests/debugger/polymorphic_output.{m,inp,exp,exp2}:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
tests/hard_coded/deconstruct_arg.m:
tests/hard_coded/elim_special_pred.m:
tests/hard_coded/existential_bound_tvar.m:
tests/hard_coded/expand.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/higher_order_type_manip.m:
tests/hard_coded/nullary_ho_func.m:
tests/hard_coded/tuple_test.m:
tests/hard_coded/type_ctor_desc.m:
tests/hard_coded/type_qual.m:
tests/hard_coded/write_xml.m:
tests/hard_coded/sub-modules/class.m:
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested2.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
tests/hard_coded/sub-modules/parent2.child.m:
tests/hard_coded/typeclasses/existential_rtti.m:
tests/recompilation/type_qual_re.m.1:
cvs update: Updating tests/submodules
cvs update: Updating tests/tabling
cvs update: Updating tests/term
cvs update: Updating tests/tools
cvs update: Updating tests/trailing
cvs update: Updating tests/typeclasses
cvs update: Updating tests/valid
tests/valid/agc_unbound_typevars.m:
tests/valid/agc_unbound_typevars2.m:
tests/valid/agc_unused_in.m:
	Replace references to the deleted predicates in std_util with
	references to the equivalent predicates in type_desc, construct
	and/or deconstruct. In test cases that already tested both the
	functionality in std_util and in the other modules, simply delete
	the part exercising std_util.
2006-03-22 02:56:44 +00:00
Julien Fischer
7fb0d8aba7 Fix the failure of this test case. It has been failing
Estimated hours taken: 0.1
Branches: main

tests/recompilation/nested_module_2_r_2.err_exp.2:
tests/recompilation/nested_module_r.err_exp.2:
	Fix the failure of this test case.  It has been failing
	since Peter Ross fixed a bug in mmake (r1.360 of modules.m)
	and, in any case, has been failing with `mmc --make' because
	it has the correct behaviour.
2006-02-06 03:52:56 +00:00
Julien Fischer
b78d146b75 Improve error reporting for type class declarations in the situation where a
Estimated hours taken: 10
Branches: main

Improve error reporting for type class declarations in the situation where a
mode declaration for a method has been provided but there is no function or
predicate declaration for that method.  Currently, this causes an internal
abort in the compiler.

Avoid another compiler abort in polymorphism.m when a type class method has two
duplicate mode declarations.

compiler/add_class.m:
	Change the order in which we add type class declarations to the HLDS
	so that we can detect and report situations where a type class method
	has a mode declaration but no corresponding predicate or function
	declaration.  All of the predicate/function method declarations for a
	particular typeclass need to be added before any mode declarations.
	We can then check that there is a corresponding predicate/function
	method declaration as each mode is added.

compiler/post_typecheck.m:
	Have the post-typechecking pass indicate that an error has occurred if
	we encounter indistinguishable mode declarations.  This prevents
	polymorphism being run if there are such mode declarations.  This
	avoids an internal abort in polymorphism.m when the mode declarations
	in question are type class methods.

	Unrelated change: s/io.state/io__state/ in an error message.

compiler/hlds_error_util.m:
	When formatting predicate names, specifically identify type class
	methods as such.  e.g. instead of `predicate foo/1' we now
	write them out as `type class predicate method foo/1'.

compiler/modecheck_call.m:
	Fix a typo: s/identical/indentical/

compiler/prog_item.m:
	Add the equivalence: class_methods == list(class_method).

compiler/equiv_type.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/prog_data.m:
compiler/prog_io_typeclass.m:
compiler/recompilation.version.m:
	Minor changes to conform to the above.

tests/README:
	Fix an line that exceeds 80 characters in length.

tests/invalid/Mmakefile:
	Enable the test cases typeclass_mode_{2,3,4} since we now pass those
	tests.

	Delete a comment about `--split-c-files'.  That option is no longer
	supported.

tests/invalid/typeclass_mode_{2,3,4}.err_exp:
	Add expected outputs for these test cases.

tests/invalid/invalid_main.err_exp:
	The module qualifier in the expected output is now '.'.

tests/invalid/qualified_cons_id2.err_exp:
	Delete the determinism error from the expected output.  It won't show
	up now as the above changes mean the compiler will abort before
	determinism checking in this case.

tests/invalid/typeclass_dup_method_mode.{m,err_exp}:
	Add a test case for the problem that causes an abort in the
	polymorphism pass when a type class method has duplicate mode
	declarations.

tests/invalid/typeclass_mode.err_exp:
	Update the expected output to conform with the above changes.  Also,
	we no longer emit the spurious error message about missing clauses.

tests/recompilation/typeclass_method_pragma_r.err_exp.2:
	Update to conform to the new naming of type class methods
	in the error message.
2006-01-16 03:08:17 +00:00
Julien Fischer
e069d16ab1 Do not display the For more information try recompiling with -E'' prompt
Estimated hours taken: 1.5
Branches: main

Do not display the `For more information try recompiling with `-E'' prompt
unless we really mean it, i.e. there is actually more information available.

XXX This change is incomplete for the mode_errors module because that
module requires more substantial changes to make this work - I'll do
that as a separate diff.

compiler/globals.m
	Add a new global (and access predicates) that keeps track of whether
	we have any verbose error information that could be displayed if we
	recompiled with `-E'.

compiler/mercury_compile.m
	Check the new global flag before prompting the user to recompile with
	`-E'.

compiler/mode_errors.m
	Add an XXX comment about needing to respect the extra error info flag
	properly.

compiler/accumulator.m
compiler/add_clause.m
compiler/add_pred.m
compiler/add_type.m
compiler/assertion.m
compiler/check_typeclass.m
compiler/det_report.m
compiler/magic_util.m
compiler/make_hlds_error.m
compiler/modes.m
compiler/module_qual.m
compiler/modules.m
compiler/post_typecheck.m
compiler/purity.m
compiler/stratify.m
compiler/typecheck_errors.m
	Set the new global flag when we come across an error
	for which we have a verbose error message.

tests/recompilation/*:
tests/invalid/*:
	Update expected error files.
2005-09-14 05:27:11 +00:00
Julien Fischer
a0e5667af5 Do not allow non-abstract instance declarations to occur in module
For review by anyone.

Estimated hours taken: 10
Branches: main, release

Do not allow non-abstract instance declarations to occur in module
interfaces.  Emit an error message if this occurs.

Fix the formatting of some error messages regarding typeclasses
and instances.

compiler/check_typeclass.m:
	Use error_util to generate the error messages from this module.
	This fixes a problem where the printing of sym_names and arities
	differed in the same error message.

compiler/error_util.m:
	Add a format component for the pred_or_func type.
	Add the equivalence type format_components.

compiler/make_hlds.m:
	Make the format of some error messages concerning typeclasses
	more consistent.

compiler/modules.m:
	Check for non-abstract instance declarations in module interfaces
	and emit an error message if they do.

tests/invalid/Mmakefile:
tests/invalid/instance_bug.m:
tests/invalid/instance_bug.err_exp:
 	Test case for the above.

tests/hard_coded/typeclasses/*:
tests/invalid/*:
tests/recompilation/*:
tests/valid/*:
	Update test cases as necessary.
2005-04-12 07:58:24 +00:00
Zoltan Somogyi
10c8d88223 Convert this module to our current coding style.
Estimated hours taken: 6
Branches: main

compiler/module_qual.m:
	Convert this module to our current coding style. Use state variables
	where appropriate. Reorder arguments as required to allow the use of
	state variables. Use error_util instead of io__write_string to print
	error messages. Use predmode declarations where possible. Use . as
	the module name separator.

	There are no algorithmic changes except for the use of error_util.

compiler/middle_rec.m:
	Convert this module to our current coding style. Use predmode
	declarations where possible.

compiler/make_hlds.m:
compiler/mercury_compile.m:
	Conform to changed argument orders of predicates in module_qual.m.

compiler/error_util.m:
	Add a new version of the utility predicate that puts commas and "and"s
	between elements of a list.

	Fix an old bug: when printing a symname/arity pair, put quotes around
	only the symname part.

tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/recompilation/*.err_exp.2:
tests/warning/*.exp:
	Update the expected error messages to reflect the better wrapping we
	get from error_util, and in some cases to reflect the fixed code for
	quotes around symnames.
2005-03-20 02:24:48 +00:00
Zoltan Somogyi
9187c0d911 Bring these modules up to date with our current style guidelines.
Estimated hours taken: 8
Branches: main

compiler/hlds_out.m:
compiler/llds_out.m:
	Bring these modules up to date with our current style guidelines.
	Use state variables in the few places where we weren't doing so
	already.

compiler/purity.m:
	Bring this module up to date with our current style guidelines.
	Use the predicates of error_util and hlds_error_util to print error
	messages. Be more consistent in using quotations. Fix indentation.

compiler/error_util.m:
	Add a long needed facility: the ability to glue some punctuation
	at the end of a previous word.

	Add a mechanism for turning a list of components into a string,
	instead of printing them out.

	Make the interface of this module more consistent by making
	list_to_pieces a function just like component_lists_to_pieces.

compiler/hlds_error_util.m:
	Change the way we describe predicates and procedures. Instead of
	returning their descriptions as single fixed strings that error_util
	can't break up across lines, return them as separate components that
	can be split across lines. This makes error output look nicer.

	Fix a mismatch between what were supposed to be corresponding pieces
	of code in hlds_error_util and hlds_out.

	Turn the appropriate predicates into functions.

compiler/*.m:
	Conform to the changed interfaces of some of the above modules.

tests/invalid/*.err_exp:
tests/invalid/purity/*.err_exp:
tests/recompilation/*.err_exp:
tests/warnings/*.exp:
	Update the expected outputs for the better looking error messages we
	now generate.
2005-01-17 05:01:48 +00:00
Julien Fischer
520f835b22 Replace deprecated mode and inst syntax in most
Estimated hours taken: 2
Branches: main

Replace deprecated mode and inst syntax in most
of the test suite.

TODO:
	Alter valid/mode_syntax.m when we start
	issuing warnings about the deprecated syntax.

tests/*/*.m:
	Replace deprecated mode and inst syntax.

	Replace some uses of `:' as the module
	qualifier.
2004-08-25 08:21:34 +00:00
Zoltan Somogyi
bc56e927b6 Detect when a predicate has a pair of I/O states but isn't det or cc_multi.
Estimated hours taken: 6
Branches: main

Detect when a predicate has a pair of I/O states but isn't det or cc_multi.
Improve the generation of determinism error messages.

compiler/det_analysis.m:
	Detect when a predicate has a pair of I/O states but isn't det or
	cc_multi.

	Factor out some common code.

compiler/det_report.m:
	Add the new error type for predicates with I/O states.

	Use error_util much more extensively to generate error messages.

compiler/hlds_out.m:
	For several existing predicates that write out various HLDS
	constructs, provide versions that return representations of those
	constructs as strings or as error_util pieces, for use by det_report.m.
	Redefine the old predicates as simply printing the output of the new
	predicates where relevant, to avoid code duplication.

compiler/error_util.m:
	When describing a predicate name, specify whether we want to module
	qualify the name or not. The intention is that when generating a kind
	of error message which can only be generated for predicates defined
	in the current module, the module prefix should be omitted in the
	interest of clarity.

compiler/accumulator.m:
compiler/dead_proc_elim.m:
compiler/magic_util.m:
compiler/table_gen.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/typecheck.m:
	Conform to the changes in error_util.m.

compiler/globals.m:
	Reorder arguments to allow the use of state variable notation.

compiler/handle_globals.m:
compiler/mercury_compile.m:
compiler/source_file_map.m:
	Conform to the changed argument order in globals.m.

tests/invalid/aditi_update_errors.err_exp:
tests/invalid/errors2.err_exp2:
tests/invalid/external.err_exp:
tests/invalid/ho_unique_error.err_exp:
tests/invalid/magicbox.err_exp:
tests/invalid/missing_det_decls.err_exp:
tests/invalid/mostly_uniq1.err_exp:
tests/invalid/mostly_uniq2.err_exp:
tests/invalid/multimode_syntax.err_exp:
tests/invalid/multisoln_func.err_exp:
tests/invalid/pragma_c_code_dup_var.err_exp:
tests/invalid/pragma_c_code_no_det.err_exp:
tests/invalid/prog_io_erroneous.err_exp2:
tests/invalid/qualified_cons_id2.err_exp:
tests/invalid/record_syntax_errors.err_exp:
tests/invalid/state_vars_test1.err_exp:
tests/invalid/state_vars_test2.err_exp:
tests/invalid/state_vars_test3.err_exp:
tests/invalid/typeclass_mode.err_exp:
tests/invalid/types.err_exp2:
tests/invalid/undef_mode_and_no_clauses.err_exp:
tests/recompilation/typeclass_method_pragma_r.err_exp.2:
tests/warnings/ambiguous_overloading.exp:
tests/warnings/duplicate_call.exp:
tests/warnings/duplicate_const.exp:
tests/warnings/infinite_recursion.exp:
tests/warnings/simple_code.exp:
tests/warnings/warn_dead_procs.exp:
tests/warnings/warn_stubs.exp:
	Update these files to expect the better error messages we now generate.
2004-05-14 08:40:33 +00:00
Peter Ross
3ccd0a4abf Disable the recompilation tests for the il grade because it
Estimated hours taken: 0.25
Branches: main

recompilation/Mmakefile:
	Disable the recompilation tests for the il grade because it
	currently doesn't support intermodule optimization.
2003-10-25 21:09:24 +00:00
Simon Taylor
c216096107 Remove the generated `.m' files.
Estimated hours taken: 0.1
Branches: main

tests/recompilation/Mmakefile:
	Remove the generated `.m' files.
2003-01-24 07:33:37 +00:00
Simon Taylor
cc220bf2b2 Remove the generated `.m' files.
Estimated hours taken: 0.1
Branches: main

tests/recompilation/Mmakefile:
	Remove the generated `.m' files.
2003-01-24 07:32:20 +00:00
Fergus Henderson
3f67a38134 Update to reflect Ralph's recent change to use .' rather than :'
Branches: main
Estimated hours taken: 0.5

tests/tabling/loopcheck.exp*:
tests/recompilation/*.err_exp.*:
	Update to reflect Ralph's recent change to use `.' rather than `:'
	as the module separator in compiler error messages.
2003-01-18 17:02:13 +00:00
Michael Wybrow
483d0c71a2 Modifications to the test suite to allow testing in grade java.
Estimated hours taken: 14
Branches: main

Modifications to the test suite to allow testing in grade java.


mercury/tools/test_mercury:
        Set-up the required CLASSPATH variable.

tests/Mmake.common:
        Added a rule to build `.out' files when the grade is java.

tests/benchmarks/Mmakefile:
        Enable only the working tests for the benckmarks directory.

tests/dppd/Mmakefile:
tests/general/Mmakefile:
tests/general/accumulator/Mmakefile:
tests/general/string_format/Mmakefile:
tests/general/structure_reuse/Mmakefile:a
tests/grade_subdirs/Mmakefile:
tests/hard_coded/Mmakefile:
tests/hard_coded/exceptions/Mmakefile:
tests/hard_coded/purity/Mmakefile:
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/typeclasses/Mmakefile:
tests/recompilation/Mmakefile
tests/term/Mmakefile:
tests/valid/Mmakefile:
        Disable test cases for grade java.

tests/recompilation/test_functions:
        Add framework needed to do recompilation testing for the java grade.
2003-01-12 22:33:35 +00:00
Simon Taylor
47a4d62dc1 Improve the test framework to make it easier to find out which tests
Estimated hours taken: 30
Branches: main

Improve the test framework to make it easier to find out which tests
failed and to reduce disk usage (important in debug grades).

Allow the tests to be run with `mmc --make' (still some failures).

Allow the user to run only the failing tests from a previous
run by using `mmake ERROR_FILE=runtests.errs', where runtests.errs
is the log file from the previous run.

tests/Mmake.common:
tests/*/Mmakefile:
	Move common code (such as the code to deal with subdirectories)
	to Mmake.common.

	Run the tests using `mmake runtests' rather than using slightly
	different runtests scripts in each directory.

	Add to the output from `mmake runtests' to make it easier to
	identify which tests failed in which grades.

	Move per-module options into Mercury.options files so they
	can be read by `mmc --make'.

	Remove the last of the NU-Prolog support.

	Consistently use the main module name when listing tests.
	Some directories (e.g. invalid) were using the source file
	name.

tests/process_log.awk:
	Collect the parts of the output relating to failing tests.

tests/generate_exp:
tests/handle_options:
tests/subdir_runtests:
tests/startup:
tests/shutdown:
tests/*/runtests:
tests/recompilation/TESTS:
	Removed.

tests/recompilation/test_functions:
	Make sure the old result file is removed before starting
	each test.

	Put the mmake output for tests which are supposed to fail
	into a different file for each test.

tests/warnings/Mmakefile:
	Use %.c rather than $(cs_subdir)%.c in a rule.
	The $(cs_subdir) part doesn't work with `mmc --make',
	and isn't necessary any more (modules.m generates a rule
	`module.c: $(cs_subdir)module.c').

tests/README:
	Updated.

tools/bootcheck:
tools/test_mercury:
	Use `mmake runtests' instead of the `runtests' script.

	Add a `-f' (`--failing-tests') option to bootcheck which
	runs only the failing tests from the last run.

tools/test_mercury:
tools/run_all_tests_from_cron:
	Use the new framework to summarize test failures.
2002-08-17 13:52:35 +00:00
Simon Taylor
b98d3d5a0e Fix bugs in the handling of predicate and function
Estimated hours taken: 1.5
Branches: main

Fix bugs in the handling of predicate and function
declarations using `with_type`.

compiler/prog_io.m:
	Fix spurious errors for `with_type` and determinism
	in the one declaration. Function declarations with
	the default modes can use this form of declaration.

compiler/mercury_to_mercury.m:
	Fix the order of `with_type` annotations and class constraints.

tests/recompilation/unchanged_with_type*:
	Test case.
2002-04-09 09:00:33 +00:00
Simon Taylor
d96f7a9bd5 Allow declarations of the form
Estimated hours taken: 40
Branches: main

Allow declarations of the form
:- pred p `with_type` higher_order_type `with_inst` higher_order_inst.

XXX We should allow `with_inst` annotations on higher-order terms.

compiler/prog_data.m:
	Add fields to `pred_or_func' and `pred_or_func_mode'
	items to hold the `with_type` and `with_inst` annotations.

compiler/prog_io.m:
compiler/prog_io_typeclass.m:
	Parse the annotations.

compiler/module_qual.m:
	Module qualify the annotations.

compiler/equiv_type.m:
	Expand away `with_type` and `with_inst`. Report errors.

	Strip items containing errors from the item list.

	Record smart recompilation dependencies on the types and
	modes expanded. Also record a dependency on the arity of
	predicate and function declarations before expansion.

	Use error_util for error messages.

compiler/mercury_to_mercury.m:
	Write `with_type` and `with_inst` annotations to interface files.

compiler/make_hlds.m:
	Ignore `with_type` and `with_inst` fields in predicate and
	function declarations.

compiler/recompilation.m:
	Changes to allow equiv_type.m to record dependencies on
	arbitrary items, not just types.

compiler/recompilation_usage.m:
compiler/recompilation_check.m:
	Allow searches in the sets of used predicates and functions using
	name, not name and arity, as the key. This is needed because
	the actual arity of a predicate defined using `with_type` is
	not known when writing the interface files.

compiler/recompilation_version.m:
	Handle `with_inst` and `with_type`.

	Pragmas now need to be recorded in the version_numbers even
	if there is no matching `:- pred' or `:- func' declaration --
	the pragma may apply to a predicate or function declared using
	`with_type`.

compiler/mode_util.m:
	Export inst_subsitute_arg_list for use by equiv_type.m.

compiler/error_util.m:
	Add predicate `pred_or_func_to_string'.

library/std_util.m:
	Add std_util__map_foldl_maybe and std_util__map_foldl2_maybe,
	which are like list__map_foldl and list__map_foldl2, but
	apply to the item stored in a value of type std_util__maybe.

NEWS:
doc/reference_manual.texi:
	Document the new syntax and library predicates.

tests/invalid/Mmakefile:
tests/invalid/with_type.m:
tests/invalid/with_type.err_exp:
tests/invalid/constrained_poly_insts.err_exp:
tests/recompilation/TESTS:
tests/recompilation/unchanged_with_type_nr*:
tests/recompilation/with_type_re*:
	Test cases.

tests/invalid/errors1.err_exp:
tests/invalid/type_loop.err_exp:
tests/invalid/vars_in_wrong_places.err_exp:
	Update expected output.
2002-03-15 07:32:27 +00:00
Simon Taylor
196fe64d90 Fix a bug in the handling of the arities of pragmas
Estimated hours taken: 0.5
Branches: main

compiler/recompilation_version.m:
	Fix a bug in the handling of the arities of pragmas
	for functions which caused recompilations to be missed.

tests/recompilation/changed_func*:
	Test case.
2002-03-10 14:56:11 +00:00
Simon Taylor
ea8ecf641a Add an option `--find-all-recompilation-reasons' which causes
Estimated hours taken: 2.5
Branches: main

Add an option `--find-all-recompilation-reasons' which causes
smart recompilation to find all reasons why a module needs to
be recompiled, not just the first. This allows test cases in
tests/recompilation to contain multiple tests. Also,
tests/recompilation will now work with deep profiling.

compiler/options.m:
compiler/handle_options.m:
doc/user_guide.texi:
	Add the new option

compiler/recompilation_check.m:
	Collect all reasons for recompilation if
	`--find-all-recompilation-reasons' is set.

tests/recompilation/Mmakefile:
	Add `--find-all-recompilation-reasons' to EXTRA_MCFLAGS.

tests/recompilation/remove_type_re.err_exp.2:
	Update expected output.
2002-02-23 07:30:59 +00:00
Simon Taylor
aeecf3074c Fix unnecessary recompilations caused by bugs in the handling
Estimated hours taken: 3
Branches: main

compiler/recompilation_version.m:
	Fix unnecessary recompilations caused by bugs in the handling
	of predicate type and `:- pragma type_spec' declarations
	containing unnamed variables.

tests/recompilation/TESTS:
tests/recompilation/type_spec_unnname_var_r*:
tests/recompilation/unchanged_pred_nr*:
	Add test cases.
2002-01-05 12:00:02 +00:00