Commit Graph

4067 Commits

Author SHA1 Message Date
Zoltan Somogyi
bdabaf5dc9 Make an error message more inclusive.
compiler/comp_unit_interface.m:
    When we cannot generate a .int0/.int/.int2 file because of file access
    issues, the reason is *usually* that we can't read a .int3 file.
    However, it is also possible that the reason is that we can't read
    a .int0 file, so include that possibility in the overall error message.
    (The "can't read this file" message, with the specifics of the file
    that couldn't be read, would have been printed earlier.)

tests/invalid_make_int/missing_parent_import.int_err_exp:
tests/invalid_make_int/sub_c.int_err_exp:
tests/invalid_make_int/test_nested.int_err_exp:
    Expect the updated error message.
2023-10-30 18:05:46 +11:00
Zoltan Somogyi
ce3e48d5ed Fix an ninth batch of C# invalid test failures.
tests/invalid/foreign_enum_invalid.{m,err_exp}:
    Delete the "foreign enum in interface" error from this test case,
    moving it to invalid_make_int/bad_in_interface.

tests/invalid/foreign_type_visibility.err_exp2:
tests/invalid/foreign_type_visibility.err_exp3:
    Add these expected outputs for Java and C# respectively.
tests/invalid/foreign_type_visibility.m:
    Document the new expected output files.
tests/invalid/foreign_type_visibility.err_exp:
    Update for changed line numbers.

tests/invalid/foreign_include_file_missing.m:
    Fix indentation.

tests/invalid/Mercury.options:
    Allow a test case to get past the creation of interface files.

tests/invalid_make_int/bad_in_interface.{m,int_err_exp}:
    Move the "foreign enum in interface" part of invalid/foreign_enum_invalid
    here.
2023-10-30 15:54:22 +11:00
Zoltan Somogyi
9b0c97b068 Add aux files for last commit. 2023-10-30 13:22:10 +11:00
Zoltan Somogyi
916a56f118 Fix an eighth batch of C# invalid test failures.
tests/invalid_make_int/bad_in_interface.{m,int_err_exp}:
    New test case containing the parts of the old test cases
    external_in_interface, fact_table_in_interface and
    foreign_proc_in_interface, all in tests/invalid_nodepend,
    that the compiler now reports when creating .int files.
    This test case replaces the external_in_interface and
    foreign_proc_in_interface test cases, since the only other thing
    they tested was the "no clauses for pred/func ..." message,
    which is also tested by several other test cases.

tests/invalid_make_int/type_vars_int.{m,int_err_exp}:
tests/invalid_make_int/unbound_type_vars_int.{m,int_err_exp}:
    New test cases containing the parts of the old test cases
    invalid_nodepend/type_vars and invalid_nodepend/unbound_type_vars
    respectively containing the errors that the compiler now reports
    when creating .int files.

tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
    List the new test cases being added to this directory.

tests/invalid_nodepend/bad_fact_table.m:
    The part of the old invalid_nodepend/fact_table_in_interface test case
    that the compiler does NOT report when creating .int files.
    Due to the removal of the parts that ARE reported at that time,
    the old name is no longer appropriate.

tests/invalid_nodepend/bad_fact_table.err_exp:
tests/invalid_nodepend/bad_fact_table.err_exp2:
    Update these two old expected output files for the changes in the
    file name and the line numbers.

tests/invalid_nodepend/bad_fact_table.err_exp3:
    Add this new expected output file for bootchecks that use mmc --make.
    (The .m file contains an explanation of its contents.)

tests/invalid_nodepend/bug410.{m,err_exp}:
    Fix a syntax error that would be reported at .int file creation time,
    and achieve its effect by simply commenting out the declaration
    whose absence results in the actual errors whose handling
    this test case is checking.

tests/invalid_nodepend/external_in_interface.{m,err_exp}:
tests/invalid_nodepend/foreign_proc_in_interface.{m,err_exp}:
    Delete these test cases, which are replaced by
    invalid_make_int/bad_in_interface.m.

tests/invalid_nodepend/fact_table_in_interface.{m,err_exp,err_exp2}:
    Delete this test case, which is replaced by
    invalid_nodepend/bad_fact_table.

tests/invalid_nodepend/type_vars.{m,err_exp}:
tests/invalid_nodepend/unbound_type_vars.{m,err_exp}:
    Delete the parts of these test cases that are now in
    invalid_make_int/{,unbound_}type_vars_int.

tests/invalid_nodepend/Mmakefile:
    Apply the two deletions and the rename to the list of test cases.

tests/invalid_nodepend/Mercury.options:
    Apply the two deletions and the rename to the list of test cases.

    Specify --no-halt-at-invalid-interface for a whole bunch of test cases,
    allowing the compiler, even Java/C# bootchecks, to proceed past
    the errors reported when creating .int files.
2023-10-30 03:24:27 +11:00
Zoltan Somogyi
dfc4e4e378 Fix a seventh batch of C# invalid test failures.
tests/invalid_make_int/bad_finalise_int.{m,int_err_exp}:
tests/invalid_make_int/bad_initialise_int.{m,int_err_exp}:
tests/invalid_make_int/bad_mutable_int.{m,int_err_exp}:
tests/invalid_make_int/bad_foreign_type_int.{m,int_err_exp}:
    New test cases containing the discoverable-at-interface-file-creation-time
    parts of the correspond test cases in tests/invalid_nodepend without
    the _int suffix on the test case name.

tests/invalid_make_int/missing_initial_section.{m,int_err_exp}:
    New test case containing the discoverable-at-interface-file-creation-time
    parts of tests/invalid_nodepend/duplicate_modes.m.

tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
    Enable the new test cases.

tests/invalid_nodepend/bad_finalise_decl.{m,err_exp}:
tests/invalid_nodepend/bad_foreign_type.{m,err_exp}:
tests/invalid_nodepend/bad_initialise_decl.{m,err_exp}:
tests/invalid_nodepend/bad_mutable.{m,err_exp}:
tests/invalid_nodepend/duplicate_modes.{m,err_exp}:
    Delete the parts of these test cases that have been moved to
    tests/invalid_make_int.
2023-10-28 02:49:39 +11:00
Zoltan Somogyi
d352b33831 Fix a sixth batch of C# invalid test failures.
compiler/check_typeclass.m:
     Don't module qualify the names of type constructors in which are
     reporting a problem regarding typeclass constraints.

tests/invalid_make_int/bad_detism_category.{m,int_err_exp}:
tests/invalid_make_int/bad_end_module.{m,int_err_exp}:
tests/invalid_make_int/bad_existential_data_type.{m,int_err_exp}:
    Move these test cases here from tests/invalid_nodepend, since
    most of the errors they report are now diagnosed when making .int files.
    Delete the code leading to the two errors that do not fall into this
    category. One of those errors is still exercised by a remnant of the
    old moved test case, which is now undetermined_existential_data_type.m
    in tests/invalid_make_int; the other is exercised by other test cases
    that this diff does not touch.

tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
    Add the moved test cases to the list of test case in this directory.

tests/invalid_nodepend/fundeps_unbound_in_ctor.err_exp:
tests/invalid_nodepend/type_vars.err_exp:
    Update these files to expect an unqualified type constructor name.

tests/invalid_nodepend/undetermined_existential_data_type.{m,err_exp}:
    Construct this copy by deleting from the old bad_existential_data_type.m
    all the code moved to tests/invalid_make_int.

tests/invalid_nodepend/Mmakefile:
    Delete the moved test case, and update the name of the remaining test case.
2023-10-28 01:34:33 +11:00
Zoltan Somogyi
68cf30cb37 Fix a fifth batch of C# invalid test failures.
compiler/det_analysis.m:
    Improve an error message about foreign_procs by printing it with
    the context of the foreign_proc itself, not the context of the
    procedure it is for. Also, make the wording more specific.

compiler/prog_event.m:
    Reading event sets is currently implemented when the compiler
    is compiled for the C backend (because its parser uses lex/flex
    and yacc/bison). However, that is no reason for crashing the compiler if
    - someone asks it to read an event set
    - while the compiler is compiled to a target language other than C.
    Fix this by returning an apology message instead of crashing.

tests/invalid/pragma_c_code_no_det.m:
tests/invalid/test_may_duplicate.m:
tests/invalid/test_may_export_body.m:
    Add foreign procs for Java and C# as well as for C.

tests/invalid/pragma_c_code_no_det.err_exp{,2,3}:
tests/invalid/test_may_duplicate.err_exp{,2,3}:
tests/invalid/test_may_export_body.err_exp{,2,3}:
    Add expected output files for Java and C#. Update the line numbers
    in the expected file for C.

tests/invalid/test_type_spec.m:
    Delete the parts of this test case that contain errors that we now report
    when creating .int files. We now test for those errors using the new test
    case tests/invalid_make_int/test_type_spec_int.
tests/invalid/test_type_spec.err_exp:
    Delete the messages for the deleted errors, expect verbose errors
    (see the update of Mercury.options below), and update the line numbers.

tests/invalid/try_detism.m:
    Explain the reason for the need for the new .err_exp2 file.
tests/invalid/try_detism.err_exp{,2}:
    Add the new .err_exp2 file for C#, which differs from the .err_exp file
    only in the variable number of a compiler-generated variable.
    Update the line numbers in the .err_exp file.

tests/invalid/undef_type.m:
    Fix the one problem in this test case that we now report when we create
    .int files. The handling of that problem is now tested in the new
    tests/invalid_make_int/undef_type_int test case.

tests/invalid/undef_type.err_exp:
    Don't expect a report for the fixed error.

tests/invalid/Mercury.options:
    Run the test_type_spec test case with verbose errors.

tests/invalid/Mmakefile:
    Don't try to execute the test cases that this diff moves to
    tests/invalid_make_int.

    Execute the test cases that try to read event set specifications
    only when targeting C. This is not the exact condition we want,
    but it is the closest to that condition that we can actually get.

tests/invalid_make_int/bad_instance.{m,int_err_exp}:
tests/invalid_make_int/type_arity.{m,int_err_exp}:
tests/invalid_make_int/undef_inst.{m,int_err_exp}:
tests/invalid_make_int/undef_mode.{m,int_err_exp}:
tests/invalid_make_int/undef_type_mod_qual.{m,int_err_exp}:
    Move these tests here from tests/invalid.

tests/invalid_make_int/test_type_spec_int.{m,int_err_exp}:
tests/invalid_make_int/undef_type_int.{m,int_err_exp}:
    The parts of the test_type_spec and undef_type test cases in tests/invalid
    that get error messages generarated for them while making .int files.

tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
    Add the tests moved here, in whole or in part, from tests/invalid.
2023-10-27 15:52:11 +11:00
Zoltan Somogyi
5193012242 Fix a fourth batch of C# invalid test fails.
compiler/add_foreign_proc.m:
    Don't module qualify the named of predicates/functions
    defined by foreign_procs when generating an error message
    about that foreign_proc, since

    - you can add foreign_procs only for local predicates/functions, and
    - even if you one for a NON-local predicate/function, the context will
      tell you exactly which foreign_proc is being complained about.

    Also, improve the wording of the error message.

tests/invalid/instances_pc.instances_pc_helper_1.err_exp2:
tests/invalid/instances_pc.m:
    Add a new expected output file for bootchecks in C# and Java grades,
    and document the new expected output file.

tests/invalid/pragma_c_code_dup_var.{err_exp2,err_exp3}:
tests/invalid/pragma_c_code_dup_var.{m,err_exp}:
    Add two new expected output files for bootchecks in C# and Java grades.
    Note the role of each expected output file, and apply the resulting
    line number changes to the expected output file for C.

tests/invalid_make_int/instance_no_type.{m,int_err_exp}:
    Move this test case from tests/invalid to tests/invalid_make_int,
    since the compiler now diagnoses the bug it tests for
    during the creation of the .int file.

tests/invalid_make_int/pragma_export_int.{m,err_exp}:
    Move half of the pragma_export test case here from tests/invalid,
    since the compiler now diagnoses the bug it tests for
    during the creation of the .int file.

tests/invalid_nodepend/pragma_export.{m,err_exp}:
    Move the other half of the pragma_export test case here from tests/invalid.
    With mmc --make, the diagnosable-at-.int-file-creation-time errors
    prevent the compiler from ever getting to the errors that are not
    diagnosable at that time, so delete the code that gives rise to those
    diagnosable-at-that-time errors from this version of the test case..

tests/invalid/Mmakefile:
    Delete the tests moved to other test directories.

tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
tests/invalid_nodepend/Mmakefile:
    Add the tests moved to these directories from tests/invalid.
2023-10-26 15:18:41 +11:00
Zoltan Somogyi
f7a06c1f24 Fix a third batch of C# invalid test fails.
compiler/make.program_target.m:
    All the multimodule tests in tests/invalid_make_int have been failing
    in C# grades. The script for these tests has two main steps:

    - build all the .int3 files involved, and then
    - build the .int file.

    The second step is expected to fail, with its error messages being tested,
    but the first step is expected to succeed. The test cases were failing
    because mmc --make built the .int files as part of the FIRST stage.

    The cause was code that built all interface files (.int3, .int0,
    .int/.int2 and even .opt) as a preliminary first step before actually
    trying to act on *any* build-all target. The fix is to make this
    preliminary step build only the interface files that come before
    the build-all target's file kind in the build order. In this case,
    that means not building anything in the preliminatu step of the
    build-all-int3s target before building all the .int3s, thus leaving
    the construction of the .int file for the second step, which is
    *expected* to fail.

tests/invalid/exported_unify_helper_1.m:
    Rename exported_unify2.m to exported_unify_helper_1.m in accordance
    with our usual scheme.

tests/invalid/exported_unify.{m.err_exp,err_exp2}:
    Update both expected error files for the rename. Since the .err_exp2 file
    was ancient, this update fixed the test case failure for C# (and almost
    certainly for Java) bootchecks. Note the role of each expected output
    file in the source code.

tests/invalid/foreign_procs_exist_type.err_exp2:
tests/invalid/foreign_procs_exist_type.err_exp3:
    Add these files containing the expected outputs for Java and C#.

tests/invalid/foreign_procs_exist_type.m:
    Add a note about the role of each expected output file.

tests/invalid/foreign_procs_exist_type.err_exp:
    Update the line numbers for this file containing the C expected output.

tests/invalid/foreign_purity_mismatch.m:
tests/invalid/fp_dup_bug.m:
    For each C foreign proc being tested, add C# and Java foreign_procs
    as well.

    Add a note about the role of each expected output file.

tests/invalid/foreign_purity_mismatch.err_exp2:
tests/invalid/foreign_purity_mismatch.err_exp3:
tests/invalid/fp_dup_bug.err_exp2:
tests/invalid/fp_dup_bug.err_exp3:
    Add these files containing the expected outputs for Java and C#.

tests/invalid/foreign_purity_mismatch.err_exp:
tests/invalid/fp_dup_bug.err_exp:
    Update the line numbers for this file containing the C expected output.

tests/invalid/gh72_errors.m:
    This test case tests an error message from the direct arg transformation.
    This transform does not apply to C# and Java grades, so in those grades,
    the compiler does not generate those messages. In those grades, this
    test case failed because the compilation succeeds, instead of failing
    (with the expected message, or not).

    Fix this failure by adding to gh72_errors.m C# and Java foreign_procs
    that do get error messages.

tests/invalid/gh72_errors.err_exp2:
tests/invalid/gh72_errors.err_exp3:
    Expect these error messages in C# and Java grades respectively.

tests/invalid/gh72_errors.err_exp:
    Update the line numbers in the error messages during C compilations.
2023-10-26 08:47:39 +11:00
Zoltan Somogyi
a3ea222883 Fix more C# test case failures in tests/invalid*.
compiler/options.m:
doc/user_guide.texi:
    Add a new developer-only option, --std-int-file-not-written-msgs,
    which, if specified, calls for the "file not written" messages
    we generate when we want to write interface files but can't
    to be written out in a standard form that deletes the directory
    path component from the names of the files not written out.
    In the long term, it is less work to add this option once
    than to add a separate .err_exp file for each affected test case.

compiler/write_module_interface_files.m:
    Obey the new option.

tests/invalid/ee_invalid.m:
    Add C# and Java foreign_types next to the C foreign_type.

tests/invalid/erroneous_throw_promise.m:
    Add C# foreign_procs next to the C and Java foreign_procs.

tests/invalid/exist_foreign_error.m:
    Add C# and Java foreign_procs next to a C foreign_proc.
tests/invalid/exist_foreign_error.err_exp:
tests/invalid/exist_foreign_error.err_exp2:
tests/invalid/exist_foreign_error.err_exp3:
    Update the line number in the expected error output file for C,
    and add expected error output files for Java and C#.

tests/invalid_make_int/bug17.{m,int_err_exp}:
tests/invalid_make_int/builtin_int.{m,int_err_exp}:
    Move these test cases here from tests/invalid, since all the errors
    we test for are reported when making the .int file.

tests/invalid/Mmakefile:
    Delete the tests moved to tests/invalid_make_int.

tests/invalid_make_int/Mercury.options:
tests/invalid_make_int/Mmakefile:
    Add the tests moved from tests/invalid. Specify the new option
    for all the test cases.
2023-10-25 19:21:06 +11:00
Julien Fischer
658385479f Fix a typo.
tests/invalid/bad_fact_table_data.m:
    We expect to match the .err_exp2 file when targeting non-C
    grades.
2023-10-24 16:27:11 +11:00
Zoltan Somogyi
c964bc5267 Fix two C# test case failures in tests/invalid.
tests/invalid/any_to_ground_in_ite_cond_nomax.m:
    Add C# and Java foreign_procs next to a C foreign_proc.

tests/invalid/bad_fact_table_data.err_exp2:
    Add the expected output for this test case in grades that
    do not support fact tables.

tests/invalid/bad_fact_table_data.m:
    Document which expected output files is expected to be matched
    in which bootchecks.
2023-10-24 14:04:23 +11:00
Zoltan Somogyi
db9d91713a Add missing C# and Java foreign_procs for a test case. 2023-10-20 14:16:57 +11:00
Zoltan Somogyi
5a57f28d03 Don't repeat an error explanation.
compiler/check_typeclass.m:
    Delete the verbose_only part of an error message, because it duplicated
    almost exactly the always-printed part of the same error message.

tests/invalid/instance_var_bug.err_exp:
    Don't expect the verbose part.

tests/invalid/bad_instance2.err_exp:
tests/invalid/invalid_instance_declarations.err_exp:
    Don't expect a reminder about the existence of the verbose part.
2023-10-19 16:09:36 +11:00
Zoltan Somogyi
df189347c4 Update an .err_exp file for a recently changed filename.
tests/invalid/bad_exported_mode.err_exp2:
    Update the name of a recently moved file in the context.

tests/invalid/bad_exported_mode.m:
    Add a comment specifying when we expect each .exp_exp* file to match.
2023-10-19 16:05:55 +11:00
Zoltan Somogyi
68c3d4040b Let callers of write_*interface_file* print errors.
compiler/write_module_interface_files.m:
    When the process of generating the contents of an interface file
    finds some errors, don't print those errors immediately. Just return
    them instead, letting the caller decide what to do with them.

    Fix comment rot.

compiler/make.get_module_dep_info.m:
compiler/mercury_compile_main.m:
    Print the error specs returned by the updated predicates (for now,
    at least).

compiler/error_sort.m:
    Fix an issue exposed by the changes above. When comparing two error_specs
    to see which one should be printed first, don't take the lack of a content
    in an error_spec as a sign that it should be printed first. Instead,
    pay attention to the comparison of contexts *only* if both of the
    error_specs being compared actually *have* contexts.

tests/invalid/type_inf_loop.err_exp:
    Expect the contextless message about exceeding the type inference
    iteration limit to come after the other messages, due to the update
    to error_sort.m.

tests/invalid/type_inf_loop.err_exp2:
    Delete this file. It can't match the compiler's current output,
    or (it seems) the output of any compiler version since we switched
    to reporting type errors using error_specs.
2023-10-08 10:11:08 +11:00
Zoltan Somogyi
c8aabea968 Fix a bug in LLDS codegen's handling of builtins.
compiler/call_gen.m:
    When a builtin generates an output that the rest of the computation
    ignores, don't update the state of the output variable(s), because
    the presence of a state for a variable that shouldn't exist
    can cause a compiler abort later.

compiler/code_gen.m:
    Pass the needed info to call_gen.m.

tests/valid/dead_get_io_state.m:
    A new test case for this bug, whose module comment explains
    the chain of events leading to the compiler abort.

tests/valid/Mmakefile:
    Enable the new test case.
2023-10-06 10:25:57 +11:00
Zoltan Somogyi
8ab02a3134 Stop littering /tmp with temp files. 2023-10-06 05:30:37 +11:00
Zoltan Somogyi
457dba0c6c Fix the failure of invalid/multiply_star in debug grades.
tests/invalid/multiply_star.err_exp3:
    Add a file for the expected error message in debug grades.

tests/invalid/multiply_star.m:
    Add a description of the reason for the difference in expected
    error messages in debug grades.

tests/invalid/Mercury.options:
    Specify verbose errors, which affects the .err_exp2 file.

tests/invalid/multiply_star.err_exp:
tests/invalid/multiply_star.err_exp2:
    Update the line numbers in the error messages.
2023-10-05 00:32:47 +11:00
Zoltan Somogyi
769412bec5 Attempt to fix a test failure in C# grades ...
... and make the set of test cases in the valid/valid_seq test directories
easier to handle.

tests/valid_seq/call_impure_in_opt_helper_1.m:
    Add a C# definition for a predicate that is defined entirely
    by foreign_procs.

tests/valid/Mmake.valid.common:
    Note the reason why many of the test cases using this file fail
    when executed in C# grades.

    Add a target that I used to debug that problem.

    Put the descriptions of a set of make variables in lexicographic order,
    except for OTHER_PROGS, which has to stay at thee end as it means
    "none of the above". Without this reordering, it was not clear that
    the cause of the failures was NOT a mistake in the spelling of
    one of these variable names.

tests/valid/Mmakefile:
tests/valid_seq/Mmakefile:
    Put the definitions of those make variables in the same order.

tests/Mmake.common:
    Improve programming style.
2023-10-02 19:01:03 +11:00
Zoltan Somogyi
f508f24b79 Extend "did you mean" suggestions beyond preds.
compiler/typecheck_error_undef.m:
    Suggest possible "did you mean" names when reporting references
    to undefined functions, not just undefined predicates.

    Generalize the infrastructure used for predicate name suggestions
    to work for function name suggestions as well.

    Delete the code moved to error_spec.m.

compiler/module_qual.qual_errors.m:
    When reporting an undefined entity name that has way to become defined
    without changing its name, suggest possible names.

compiler/error_spec.m:
    Move the code for constructing "did you mean" suggestions here from
    typecheck_error_undef.m, to make it accessible from
    module_qual.qual_errors.m as well.

compiler/hlds_cons.m:
    Add a way to retrieve the names of all the function symbols,
    for use by the new code in typecheck_error_undef.m.

compiler/module_qual.id_set.m:
    Add a way to retrieve the names of all the ids in an id_set,
    for use by the new code in module_qual.qual_errors.m.

    Expand a old comment.

tests/invalid/bug113.err_exp:
tests/invalid/multiply_star.err_exp:
tests/invalid/multiply_star.m:
tests/invalid_nodepend/kind.err_exp:
tests/invalid_nodepend/reserved_type_name.err_exp:
    Expect the "did you mean" messages we now generate.
2023-09-26 18:51:18 +10:00
Zoltan Somogyi
427f67ffda Allow module qualification using mixed operators ...
... such as a__b.c__d.

compiler/parse_sym_name.m:
    Allow the operands of terms module qualified with "." to contain
    terms module qualified with "__".

    Stop allowing ":" as a module qualifier.

compiler/parse_dcg_goal.m:
compiler/parse_goal.m:
    Make the code parsing DCG and non-DCG goals as similar as possible.

tests/invalid/qual_basic_test2.err_exp:
    Expect "io.io__write_string" to be parsed as "io.io.write_string".

tests/invalid_make_int/test_nested_helper_1.test_nested_helper_3.m:
tests/invalid_make_int/test_nested_helper_1.test_nested_helper_4.m:
tests/invalid_make_int/test_nested_helper_2.test_nested_helper_6.m:
tests/invalid_submodules/nested_impl_in_int.m:
    Stop using ":" as module qualifier.
2023-09-26 01:59:33 +10:00
Zoltan Somogyi
c69b7e4b9a Add "did you mean ..." to undef pred reports.
compiler/typecheck_error_undef.m:
    If we are reporting an error for a reference to an undefined predicate,
    check whether any predicates exist whose names are "close enough"
    to the name of the referenced predicate, and if yes, add to the
    error message a line containing "(Did you mean x, y or z?)".

    (Doing the same for references to undefined functions is future work.
    The two are separate because things that look like function references
    can also refer to e.g. data constructors.)

library/edit_distance.m:
    Add this new module to implement the "close enough" check.
    This new module is similar to the existing edit_seq.m module,
    but it is designed to serve different requirements, and it seems to me
    to be far from trivial to write code to meet both sets of requirements
    at once.

library/library.m:
library/MODULES_DOC:
    Include the new module in the standard library.

NEWS.md:
    Announce the new library module.

tests/hard_coded/edit_distance_test_closest.{m,exp}:
tests/hard_coded/edit_distance_test_cost.{m,exp}:
    Two new test cases, each of which tests one of the two predicates
    exported by the new library module.

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

tests/invalid/qual_basic_test2.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/undef_symbol.err_exp:
tests/invalid_submodules/undef_mod_qual.err_exp:
    Expect the new "did you mean" additions to error messages.
2023-09-26 00:56:19 +10:00
Zoltan Somogyi
1171e89bc9 Rename X's aux modules as X_helper_N in tabling. 2023-09-18 21:54:30 +10:00
Zoltan Somogyi
986c054788 Fix programming style in some tests. 2023-09-18 21:54:05 +10:00
Zoltan Somogyi
782ac5184c Rename X's aux modules as X_helper_N in valid_make_int. 2023-09-18 21:13:14 +10:00
Zoltan Somogyi
34c3f3ac2d Rename X's aux modules as X_helper_N in typeclasses. 2023-09-18 21:12:36 +10:00
Zoltan Somogyi
a0d6710407 Use "ts=4 sw=4 expandtab" as modeline ...
... in Mercury.options files.
2023-09-16 19:12:52 +10:00
Zoltan Somogyi
a6c7a5d245 Rename X's aux modules as X_helper_N in valid. 2023-09-16 14:19:42 +10:00
Zoltan Somogyi
ff50a9e680 Rename X's aux modules as X_helper_N in warnings. 2023-09-16 12:14:42 +10:00
Zoltan Somogyi
49804a2580 Fix style in a test. 2023-09-16 02:07:56 +10:00
Zoltan Somogyi
7f64f6eae3 Rename X's aux modules as X_helper_N in valid_seq.
Do this after renaming the main modules of tests that either

- had names that did not even attempt to describe what problem
  they were intended to test for, or
- had names that include either a "test_" prefix or a "_main" suffix.

This ended up renaming most of the modules in this directory. The reason
for this is that many tests' names had an "intermod_" or "nested_" prefix.
This was useful in the valid directory, where these tests originally were,
but it is not useful here, since these tests are in the valid_seq directory
to be executed sequentially *precisely because* they involve multiple modules.

The set of renames of main modules are is:

    func_int_bug_main               ->  func_int_bug
    intermod_bug_nested             ->  spurious_match
    intermod_char                   ->  char_escape_opt
    intermod_dcg_bug                ->  dcg_bug
    intermod_impure                 ->  call_impure_in_opt
    intermod_lambda                 ->  exported_lambda
    intermod_nested                 ->  to_submods_opt
    intermod_nested_module          ->  read_submod_opt
    intermod_nested_module_bug      ->  mode_from_int0_opt
    intermod_nested_uniq            ->  head_var_unify_uniq
    intermod_quote                  ->  opt_file_quote
    intermod_record                 ->  field_access_funcs
    intermod_test                   ->  overload_resolution
    intermod_type_spec              ->  type_spec_vars
    intermod_typeclass_exist        ->  typeclass_exist_opt
    intermod_typeclass              ->  typeclass_in_opt
    intermod_pragma_import          ->  foreign_proc_import
    intermod_ua_type_spec           ->  unused_args_type_spec
    intermod_user_equality_nested   ->  user_eq_pred_nested
    intermod_user_equality          ->  user_eq_pred_nonnested
    intermod_user_sharing           ->  sharing_in_opt
    module_a                        ->  indirect_import_two_paths
    module_b                        ->  indirect_import_one_path
    module_c                        ->  DELETED
    module_d                        ->  DELETED
    module_e                        ->  DELETED
    nested_module_bug               ->  nested_module_ambiguity
    nested_mod_type_bug             ->  type_exported_to_submods
    parsing_bug_main                ->  parsing_bug
    test_xmlreader                  ->  xmlreader

Each of the new main modules includes a note about its previous name.

The old files module_[bcd].m were each used by two or more tests,
definitely including module_a and module_b, and including
module_c and module_d for some of them. The module_c and module_d tests
did not test anything that module_b did not test, and the module_e test
did not test anything useful at all, which is why this diff deletes them.
The diff also ensures that the module_a and module_b tests, under their
new names, now used disjoint sets of helper modules.

Add a note to module_a, under its new name, indirect_import_two_paths,
that despite an original log message saying that it tests importing
the same module via both direct and indirect paths, there is no actual
indirect import of the module in question.
2023-09-10 15:54:13 +10:00
Julien Fischer
7d1889bdbf Fix a typo.
tests/options_file/Mmakefile:
    Redirect stderr to stdout rather than a file named "1".
2023-09-08 15:21:54 +10:00
Zoltan Somogyi
f6c0835246 Move tests/valid/empty_submodule.m to valid_seq.
It contains a submodule, and parallel mmake can cause spurious failures.
2023-09-08 12:19:53 +10:00
Zoltan Somogyi
7b21fcfe0a Fix an old fat-fingered update to this .exp file. 2023-09-07 08:55:42 +10:00
Zoltan Somogyi
0528eeb78e Fix out-of-date references to changed subdir names. 2023-09-06 19:47:06 +10:00
Zoltan Somogyi
76ddf450b4 Delete stray .err_exp2 file.
Its test was moved to a different test directory, and the file
has suffered bit rot.
2023-09-04 15:27:48 +10:00
Zoltan Somogyi
8e32ce0c7f Allow use_module declarations in .int2 files ...
... for modules referenced in the definitions of equivalence types.

compiler/comp_unit_interface.m:
    Add use_module declarations for modules referenced by the right hand sides
    of equivalence type definitions to the implementation sections of .int2
    files.

    Update the names of some of the predicates involved.

    Make the definitions of the predicates accumulate_modules_in_type and
    accumulate_modules_in_qual_type, which do *almost* the same job,
    as similar to each other as possible.

compiler/make_hlds_separate_items.m:
    Allow use_module declarations in the implementation sections of .int2
    files.

compiler/grab_modules.m:
    Ensure that we grab the .int2 files of any modules that have use_module
    declarations for them in the implementation sections of .int2 files.

tests/valid_seq/bug563.m:
tests/valid_seq/bug563_helper_1.m:
tests/valid_seq/bug563_helper_2.m:
    The test case from the Mantis bug report, renamed.

tests/valid_seq/Mmakefile:
    Enable the new test case.
2023-09-04 15:00:38 +10:00
Zoltan Somogyi
0c76e78ed6 Factor out common code in error_msg_inst.m.
compiler/error_msg_inst.m:
    Most parts of this module consisted of pairs of predicates following
    the naming scheme X_to_pieces and X_to_inline_pieces. Replace each such
    pair of predicates with one predicate that takes a flag that says
    which version we want, since this allows us to avoid doing double
    maintenance. (The overall logic of the two versions was always the same;
    the differences affected only the construction of the piece sequence.)

    Get the compiler to recreate the original pair of procedures
    by using two separate specialized mode declarations to require
    the callers of each such predicate to specify whether they want
    to generate multi line or inline piece sequences.

    Move the !Expansion argument pairs to the end of the argument list
    in each of the updated predicates, in order to conform to our usual
    programming style.

    Eliminate differences between the codes used to construct the multi line
    and inline piece sequences that had no effect on the final output.

    Fix three minor bugs in the process.

    The first bug was that inst_name_to_pieces, which was intended to generate
    structured multi line inst descriptions, called inst_to_inline_pieces
    instead of inst_to_pieces in some cases.

    The second bug involved code in pred_inst_info_to_pieces and its inline
    version to special case the formatting of higher order values with no
    arguments. (The special casing omits what would be an empty pair of
    parentheses around the empty argument list.) While this is the right thing
    to do for predicates, it is nonsense for functions, because functions
    have at least one argument: the return value. Fix the code to special case
    functions having no *non-return-value* arguments.

    The third bug was a call to component_lists_to_pieces which could generate
    a list of argument modes in pred_inst_info_to_pieces and its inline version
    that could leave the last two modes *not* being separated by a comma.

tests/invalid/bug415.err_exp:
    Update this expected output to account for the first bug fix.
2023-08-30 06:52:49 +10:00
Zoltan Somogyi
1d2b4bf503 Improve the style of a test case. 2023-08-23 01:53:43 +02:00
Julien Fischer
d9b282d6f7 Fix a failing test on MinGW64/UCRT64.
tests/declarative_debugger/Mmakefile:
     Avoid hardcoding a memory address in the expected output for
     the declarative_debugger/condition_bug test case.
2023-08-20 14:47:24 +10:00
Zoltan Somogyi
eba4f307d9 Add inst_lookup_debug, and use it to fix a bug.
compiler/inst_lookup.m:
    Add inst_lookup_debug, a new version of the inst_lookup predicate
    intended to debug problems with inst names. It can recognize and report
    without crashing two kinds of problems with inst names:

    - unknown inst names, situations in which an inst name identifies
      an entry in an inst table that indicates that an operation on insts
      has begun but has not yet completed, which is a problem if all such
      operations are supposed to have completed, abd

    - missing inst names, situations in which an inst name *should* identify
      an entry in an inst table, but that entry does not exist. In such cases,
      the inst name is effectively a form of dangling pointer.

    It reports both kinds of problems by return user insts of a special form
    that another predicate can recognize, and which contain all the info
    available about the error.

compiler/hlds_inst_mode.m:
    Add predicates to search the inst tables, to allow inst_lookup_debug
    to use its own code to handle search failures.

    Add predicates to return the contents of the four subtables of the
    unify inst table separately, and to rebuild the unify inst table
    from the versions of those four components. This is to help with
    a change to equiv_type_hlds.m that is explained below.

    Delete a no-longer-needed predicate.

compiler/parse_tree_to_term.m:
    Export some utility functions for use by inst_lookup_debug.

compiler/error_msg_inst.m:
    Use inst_lookup_debug instead of inst_lookup to "look up" inst names.
    When this returns an indication of an error, format the component insts
    of the erroneous insts nicely.

compiler/hlds_out_inst_table.m:
    When we print out entries in the unify inst table, merge inst table
    and the other inst tables, make it easier to see *which* table's entry
    we are looking at.

compiler/equiv_type_hlds.m:
    Fix a bug. The bug was this code in expanding out equivalence types
    in merge_inst_infos:

    ( if ChangedA = unchanged, ChangedB = unchanged then
        Changed = unchanged,
        MergeInstInfo = merge_inst_info(InstA, InstB)
    else
        Changed = changed,
        MergeInstInfo = MergeInstInfo0
    ).

    The lack of the update in the changed case led to properly-updated
    merge insts becoming dangling insts, which caused a compiler abort
    on their next lookup in the merge inst table. The reason why this
    bug hasn't appeared before is that such lookups are rarely done
    after equiv_type_hlds is invoked.

    Change a lambda expression involved in this bug to a predicate,
    to simplify putting an mdb breakpoint on it.

    Since the error may have been caused by the inconsistency of

    - some switches on Changed having the unchanged case first,
    - with other switches on Changed having the changed case first,

    make all switches put the unchanged case first, checking that
    none make the same mistake.

    Expand out type equivalences in each of the four subtables of the
    unify inst table separately, to both simplify and speed up the process
    of getting the key/value pairs out of the table and putting them
    back again.

tests/valid_seq/merge_inst_bug.m:
tests/valid_seq/merge_inst_bug_helper_1.m:
    Add a cut-down version of the original bug report program
    as a regression test.

tests/valid_seq/Mmakefile:
    Enable the new test case.
2023-08-13 12:39:56 +02:00
Zoltan Somogyi
97441ce3fe Simplify the code adding foreign_proc to the HLDS.
compiler/add_foreign_proc.m:
    Simplify the if-then-else chain that checks whether a foreign_proc
    should be added to the HLDS, and if not, what, if any, error message
    should be generated for it.

    Document two separate factors that complicate the cases that
    this chain has to deal with. Name the test cases that exemplify
    those complications.

compiler/hlds_pred.m:
    Activate an old commented-out optimization.

tests/hard_coded/foreign_type2.m:
    Put the contents of this test case (one of the ones now listed in
    add_foreign_proc) into a logical order. The reordering does not affect
    the substance of the test.
2023-08-03 03:30:20 +02:00
Julien Fischer
9656e13e73 Fix some declarative debugger test on Windows.
tests/declarative_debugger/Mmakefile:
    Filter memory addresses and error codes from the output of the
    condition_bug and sort tests.

tests/declarative_debugger/sort.exp:
    Conform to the above change.

tests/Mmake.common:
    Shut up an error from grep when a directory does not contain
    a FAILED_TESTS file.
2023-07-30 13:33:46 +10:00
Zoltan Somogyi
f3b31079db Run tests/invalid/test_feature_set with --no-intermod-opt.
Intermodule optimization is irrelevant to its purpose,
and without it, it now gets errors for .opt file grade mismatch.
2023-07-29 02:45:21 +02:00
Julien Fischer
85e84f4f62 Fix the failure of hard_coded/runtime_opt on Windows.
tests/hard_coded/runtime_opt.exp2:
    Alternative expected output for where stdout and stderr are
    interleaved differently.

tests/hard_coded/runtime_opt.m:
    Document what the expected outputs are for.
2023-07-28 20:20:19 +10:00
Julien Fischer
02a5945b77 Fix the failure of declarative_debugger/io_stream_test ...
... in debug grades on Windows.

tests/declarative_debugger/Mmakefile:
     Account for the fact that Windows prints pointers differently.
2023-07-28 20:10:10 +10:00
Julien Fischer
f956c57754 Fix the failure of debugger/tabled_typeclass ...
... in debug grades on Windows.

tests/debugger/Mmakefile:
     Account for the fact that Windows prints pointers differently.
2023-07-28 19:19:56 +10:00
Julien Fischer
c2624c6951 Fix the failure of debugger/nondet_stack with MinGW64.
tests/debugger/Mmakefile:
     Expect lowercase hex digits in the output on Windows.
2023-07-26 20:37:25 +10:00
Zoltan Somogyi
75320f5d14 Update the error message for missing ho insts.
compiler/mode_errors.m:
    Improve the error message you get when you pass a higher order value
    without specifying its higher order inst, along the lines in the
    discussion on m-rev over the last week.

compiler/error_msg_inst.m:
    Make some variables more descriptive.

tests/invalid/no_ho_inst.err_exp:
    Update the expected error message.
2023-07-25 00:16:24 +02:00