24815 Commits

Author SHA1 Message Date
Peter Wang
04a5200293 Check for null TypeInfo.args array.
library/type_desc.m:
    Check for TypeInfo.args == null to avoid a null pointer exception.
    This is necessary for the Java grade.

    Make the corresponding change for C# grade for consistency,
    though it does not appear to be necessary.
2025-09-08 17:26:09 +10:00
Zoltan Somogyi
80943c1142 Fix some Java/C# test case failures.
library/rtti_implementation.m:
    Return zero arity for null TypeInfo.args arrays. This fixes the
    failure of the hard_coded/pretty_printing test case in the Java grade,
    and probably in the C# grade as well.

tests/general/read_dir_regression.m:
    Fix the failure of the failure of this test case in the Java grade,
    by massaging the error message returned for an intentionally-failed
    open of a directory as a plain file. When opening ".", the error message
    (on my laptop, at least) returns the full absolute path name of the
    current directory. Since this will be different in different workspaces,
    we can't update the expected output file, but we can replace this
    changeable part of the error message with a fixed string. This diff
    does this.

tests/hard_coded/ho_solns.m:
    Add a note about the cause of the failure of this test case.

tests/hard_coded/string_code_point.exp2:
    Conform to the old switchover from the "codepoint" spelling
    to "code_point".
2025-09-04 23:44:40 +02:00
Zoltan Somogyi
0335abce8b Fix an old oversight. 2025-09-03 18:35:13 +02:00
Zoltan Somogyi
e8928151a7 Don't loop over non-existent submodules. 2025-09-03 18:34:24 +02:00
Zoltan Somogyi
c690fac030 Rename tests that duplicate library module names.
These interfere with tests in this directory with mmc --make.
2025-09-03 18:28:54 +02:00
Zoltan Somogyi
feeff5d8b3 Expect updated/colorized error messages. 2025-09-03 18:15:07 +02:00
Zoltan Somogyi
078d110e23 Avoid an unneeded warning. 2025-09-03 18:12:39 +02:00
Zoltan Somogyi
ba74b16eae Shorten too-long lines. 2025-09-03 18:11:59 +02:00
Zoltan Somogyi
2c50256e4a Fix disappearing directories in tests/feedback.
tests/feedback/mandelbrot_dir:
tests/feedback/mmc_dir:
    Add "_dir" suffixes to the names of these two subdirectories.
    The reason is that when doing a bootcheck in the java or C# grades,
    which always use mmc --make, the realclean action we executed
    for each test, mandelbrot and mmc, in this directory,
    deleted these directories, because their names coincided
    with the names of what would have been the executables
    in these tests. (Of course, part of the problem is that
    the realclean action effectively executed "rm -r" instead of
    just "rm" when it *thought* it was removing an executable.)

tests/feedback/Mmakefile:
    Tell the tests to get the deep profiling data files from the
    updated directory names.
2025-09-03 18:10:25 +02:00
Zoltan Somogyi
113e366249 Keen another import private. 2025-09-01 08:15:51 +02:00
Peter Wang
93683479cc Fix typo in help text. 2025-09-01 11:25:45 +10:00
Zoltan Somogyi
2344aa422b Modernize the code of mfilterjavac. 2025-09-01 02:22:47 +02:00
Zoltan Somogyi
0f6d21ee13 Move an import. 2025-08-31 19:26:00 +02:00
Zoltan Somogyi
54f12a0608 Use similar code to compile high and low level C.
And give more consistent names to some predicates.

compiler/mercury_compile_augment.m:
    Move the code that controls the compilation of .c files to .o
    for the LLDS backend here from mercury_compile_llds_back_end.m,
    to allow the similarities and dissimilarities between the MLDS
    and LLDS backends to be seen easily.

    Delete the part of the moved code that wrote out .mh files
    for a SECOND time.

    Rename some predicates.

compiler/mercury_compile_llds_back_end.m:
    Delete the code moved to mercury_compile_augment.m. Export some
    predicates needed by the moved code.

compiler/mercury_compile_mlds_back_end.m:
    Rename a predicate.

compiler/export.m:
    Simplify the interface of this module.
2025-08-31 18:11:16 +02:00
Zoltan Somogyi
83595c258c Update the description of module compilation.
doc/mercury_user_guide.texi:
    Fit the compilation section into its new position.

    Fix the description of C# compilation.

scripts/mgnuc.in:
    Change the help message NOT to assume that the C compiler is gcc,
    since we have supported other C compilers as well for a long time.

    Move a comment to the code it applies to.

compiler/mercury_compile_augment.m:
    Add a comment.

compiler/export.m:
    Replace /* */ C commments with // commments.
2025-08-31 15:24:56 +02:00
Zoltan Somogyi
47fd3440d9 Move a section to its chronological position. 2025-08-31 13:38:26 +02:00
Zoltan Somogyi
b40e52d174 Fix too-long lines. 2025-08-31 12:47:10 +02:00
Julien Fischer
dfa8d2411c Fix a texinfo error.
docs/mercury_user_guide.texi:
   Replace an invalid item marker.
2025-08-31 00:57:39 +10:00
Zoltan Somogyi
f0ad6bb5c6 Fix typos. 2025-08-30 12:47:51 +02:00
Zoltan Somogyi
b8d5ea9d6c Finish first draft of intermodule opt section. 2025-08-29 19:34:50 +02:00
Zoltan Somogyi
108e221cfb Rename --generate-module-order to --also-output-module-order,
... and change the extensions of the files to which it writes its output, from
.order and order_trans_opt to .module_order and .module_order_for_trans_opt.

compiler/options.m:
    Change the name of the option from --generate-module-order
    to --also-output-module-order, while keeping the old external name
    as well for now. Update its documentation accordingly.

    Document the private option --trans-opt-deps-spec more extensively.

compiler/file_names.m:
    Change the extension strings we use for those two files.

NEWS.md:
    Announce the change in the option name and in the *public* file extension.

compiler/opt_deps_spec.m:
    Refer to the option by its new internal name.

tests/warnings/help_text.err_exp:
    Expect the updated option names and help text.
2025-08-29 17:16:43 +02:00
Zoltan Somogyi
7a35acc17a Use consistent terminology.
compiler/quantification.m:
    Consistently use "NonLocals" to refer to these sets. Previously,
    many predicates used that terminology, but many others used
    "NonLocalVars". "NonLocals" is what we use in the rest of the compiler.

    Document the quant_info structure better.
2025-08-29 12:10:19 +02:00
Zoltan Somogyi
990a4e1f0a Make some code more readable.
compiler/quantification.m:
    Define and use data types for explicitly associating goals
    in conjunctions with the variables that occur after them
    in the conjunction. This requires allocating a bit more memory,
    but allows us to replace iterating over two lists with iterating
    over one list. There is no measurable effect on overall performance.
2025-08-29 01:22:42 +02:00
Zoltan Somogyi
e135433e32 Delete an unneeded parameter.
It was updated from the default once upon a time, but that code
was disabled long ago, and its value has been constant ever since.
2025-08-29 01:04:10 +02:00
Zoltan Somogyi
fc8b2294c3 Make some imports private. 2025-08-29 00:50:24 +02:00
Zoltan Somogyi
e9f3f6ec1b Impose top-down order on superhomogeneous.m.
Document the operations of some predicates.

Eliminate unnecessary inconsistencies between variable names.
2025-08-27 17:29:47 +02:00
Zoltan Somogyi
b6875c1646 Use standard length section dividers. 2025-08-27 17:25:20 +02:00
Zoltan Somogyi
b7b4e12dc8 Carve two new modules out of superhomogeneous.m.
compiler/superhomogeneous_lambda.m:
    Carve the code handling lambda expressions out of superhomogeneous.m.
    This code was about 49% of the code of the module.

compiler/superhomogeneous_util.m:
    Carve some utility types and predicates out of superhomogeneous.m,
    since it now also needed by superhomogeneous_lambda.m.

    Also, delete the unused function unify_var_term_project_var.

compiler/superhomogeneous.m:
    Delete the moved code.

compiler/make_hlds.m:
compiler/notes/compiler_design.html:
    Include and document the new modules.

compiler/add_clause.m:
compiler/field_access.m:
compiler/goal_expr_to_goal.m:
    Conform to the changes above.
2025-08-27 15:09:04 +02:00
Zoltan Somogyi
989768f226 Fix old typo. 2025-08-27 13:44:31 +02:00
Zoltan Somogyi
cd8187ae2a Fix compilation of mmsc grades. 2025-08-25 15:48:28 +02:00
Zoltan Somogyi
e1a9eb733c Give some predicates more descriptive names ...
... and move a predicate to be with similar predicates.

compiler/typecheck_util.m:
    Move the typecheck_var_has_type_2 predicate here from typecheck_clauses.m,
    give it a more descriptive name, and give it a simpler-to-understand
    interface.

    Give another predicate a more descriptive name as well.

compiler/typecheck_clauses.m:
    Delete the predicate moved to typecheck_util.m.

    Conform to the changes above.

compiler/typecheck_unify_var_functor.m:
    Conform to the changes above.
2025-08-25 15:42:53 +02:00
Julien Fischer
b7685aae5f Disable concurrency in non .par LLDS grades.
The non .par LLDS grades currently "support" concurrency. However, this support
is really only usable with a small few benchmark programs, due to the inability
of the implementation to switch threads if the executing thread blocks. Disable
this capability by causing spawn/3 to abort if used in non .par LLDS grades.

library/thread.m:
    Make the above change to spawn/3.

compiler/globals.m:
    Update the code that checks if the current grade supports concurrency.

compiler/options.m:
    Adjust documentation for the --parallel option.

tests/warnings/help_text.err_exp:
    Conform to the above change.
2025-08-21 22:08:48 +10:00
Zoltan Somogyi
4cd6d7c8a0 Fix markup. 2025-08-20 21:17:17 +02:00
Julien Fischer
c02ea43780 Fix markup in NEWS file.
NEWS.md:
    As above.
2025-08-20 20:07:25 +10:00
Peter Wang
9f66809257 Fix texinfo syntax. 2025-08-20 10:50:33 +10:00
Zoltan Somogyi
00f3632b33 Add some notes to opt_deps_spec.m.
Enable an optimization for it, and for another module.
2025-08-19 19:51:11 +02:00
Zoltan Somogyi
089be6d2d8 Address review comments. 2025-08-19 19:50:37 +02:00
Zoltan Somogyi
7834e905c8 Address review comments. 2025-08-18 18:38:28 +02:00
Zoltan Somogyi
1f259e7a80 End .order files with a newline.
Construct out the file on a line-by-line basis.
Create it using string.builder, and write it out at the end.
2025-08-18 17:53:41 +02:00
Zoltan Somogyi
07f43b780a Indent an action better in an mmake fragment. 2025-08-18 17:43:07 +02:00
Zoltan Somogyi
ca20c38987 Split --warn-redundant-code from --warn-simple-code.
compiler/options.m:
    Move --warn-simple-code to the "warnings about dodgy code"
    category, as

    - most of the issues that it warns about are indeed evidence
      of dodgy code, and
    - its existing documentation also states that it is intended
      to report likely-to-be-incorrect code.

    Change the internal name of --warn-simple-code, in order to force
    all its existing uses to be reclassified.

    Let the --warn-redundant-code part stay in the style issues category,
    since the code will work just the same if the redundancies are removed.

NEWS.md:
    Announce the new option.

compiler/simplify_goal_call.m:
    Reclassify all uses of --warn-simple-code.

    Add a missing condition in an if-then-else.

compiler/add_clause.m:
compiler/add_type.m:
compiler/check_type_inst_mode_defns.m:
compiler/convert_import_use.m:
compiler/convert_parse_tree.m:
compiler/det_analysis.m:
compiler/det_infer_goal.m:
compiler/mercury_compile_front_end.m:
compiler/mode_errors.m:
compiler/simplify_goal.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/simplify_info.m:
compiler/simplify_tasks.m:
compiler/state_var.m:
    Reclassify all uses of --warn-simple-code.

tests/warnings/help_text.err_exp:
    Expect the updated help text.
2025-08-18 14:53:08 +02:00
Zoltan Somogyi
a0769526e6 Rename three options from inform_X to warn_X.
compiler/options.m:
    Rename the internal names of these three options. Keep the old
    external names, but make the main external name the new name.

NEWS.mdb:
    Announce the renames.

compiler/check_options.m:
compiler/det_check_proc.m:
compiler/det_check_switch.m:
compiler/simplify_goal_ite.m:
    Conform to the change above. Change the severity of the messages
    controlled by the changed options severity_warning.

tests/warnings/help_text.err_exp:
    Expect the updated help text.
2025-08-18 13:13:10 +02:00
Zoltan Somogyi
e6981b2835 Reorder some predicates. 2025-08-18 12:15:17 +02:00
Zoltan Somogyi
823de2d37b Require warning/info messages to specify an option.
The objective of this step is two-fold:

- to fix --inhibit-warnings, making it shut up all warning
  and informational messages; and

- to ensure that it *stays* fixed, even when after new diagnostics
  are added.

As part of this fix, this diff adds a whole bunch of new warning
options, in order to control the warnings that previously were
not controlled by any option. (There was no need for new
informational options.)

As it happens, we have long used severity_informational for messages
that did not report any information about the code being compiled,
but to report actions that the compiler was taking. Create a new
option category, oc_report, for the new options that now control
those diagnostics.

---------------------

compiler/error_spec.m:
    Change severity_warning and severity_informational to take an option
    as as argument. The semantics is that the diagnostic in which
    the severity occurs is conditional on that option, meaning that
    it is printed only if that option is set to "yes".

    Delete the severity_conditional function symbol from the severity
    type, since the mechanism just above handles its only use case.

    Define subtypes to represent error_specs in a standard form.

compiler/error_sort.m:
    Provide operations to convert error specs into their standard form.

    Make the sorting operation itself operate on the standard form.

compiler/write_error_spec.m:
    Convert error_specs to standard form before writing them out,
    in order to avoid duplicating the code for their standardization.

    Change the code that writes out error_specs to operate on the
    standard form. Implement the test implicit in the warning and
    and informational severities in this code.

compiler/error_util.m:
compiler/compiler_util.m:
    Delete operations that do not make sense with the new severity type.

---------------------

compiler/options.m:
    Add new options to control all the previously-uncontrolled
    warning and informational messages.

NEWS.md:
    Announce the *public* new options.

compiler/option_categories.m:
compiler/print_help.m:
    Add the new option category, and fake-include it in the help text
    and the user guide. (The inclusion is fake because none of the
    options in the new category are user visible, meaning the section
    containing them is not visible either.)

---------------------

compiler/det_infer_goal.m:
    Start a severity warning diagnostic with "Warning:"
    instead of "Error:".

compiler/mark_trace_goals.m:
    Fix an incorrect error message.

compiler/purity.m:
    Replace a correct/incorrect color pair with two inconsistent colors,
    because there is a reasonable probability of each one being right.

---------------------

compiler/accumulator.m:
compiler/add_clause.m:
compiler/add_mode.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/check_module_interface.m:
compiler/check_type_inst_mode_defns.m:
compiler/check_typeclass.m:
compiler/color_schemes.m:
compiler/common.m:
compiler/convert_import_use.m:
compiler/convert_parse_tree.m:
compiler/dead_proc_elim.m:
compiler/det_check_proc.m:
compiler/det_check_switch.m:
compiler/det_infer_goal.m:
compiler/du_type_layout.m:
compiler/format_call_errors.m:
compiler/grab_modules.m:
compiler/hlds_call_tree.m:
compiler/inst_check.m:
compiler/introduce_parallelism.m:
compiler/make_hlds_error.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mark_trace_goals.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/opt_deps_spec.m:
compiler/options_file.m:
compiler/parse_goal.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/pre_typecheck.m:
compiler/purity.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/simplify_goal.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/split_parse_tree_src.m:
compiler/state_var.m:
compiler/stratify.m:
compiler/style_checks.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/typecheck_clauses.m:
compiler/typecheck_error_overload.m:
compiler/typecheck_error_undef.m:
compiler/typecheck_errors.m:
compiler/typecheck_msgs.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/warn_unread_modules.m:
compiler/write_module_interface_files.m:
    Conform to the changes above, mostly by either

    - adding an option to all warning and informational messages,
      sometimes using existing warning options and sometimes new ones,
      or

    - turning already explicitly-conditional-on-an-option messages
      into implicitly-conditional-on-that-option messages.

---------------------

tests/invalid/one_member.m:
    Conform to the change in det_infer_goal.m.

tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_2.err_exp:
    Actually obey the options for these modules in Mercury.options.

tests/invalid_purity/purity.err_exp:
tests/warnings/purity_warnings.err_exp:
    Conform to the change in purity.m.

tests/warnings/moved_trace_goal.err_exp:
    Conform to the change in mark_trace_goals.m.

tests/warnings/help_text.err_exp:
    Expect the documentation of all the new options.
2025-08-18 12:07:38 +02:00
Zoltan Somogyi
ecff38234e Fix some stray ZZZs. 2025-08-17 17:32:40 +02:00
Julien Fischer
18a9e4741c Delete old code for invoking the C# compiler.
There are currently two separate predicates used for invoking the C# compiler.
One is in link_target_code and is used to create executables and libraries
in the C# grade. The other is compile_target_code and was previously used
by the old .NET backend to compile additional C# source files. It is currently
plugged into the code that compiles the source files used for fact tables, but
as they are not supported by the C# backed, it has never been used in practice
for this purpose.

Delete the code for invoking the C# compiler in compile_target_code, since it
will have no users after this diff and is almost certainly affected by bitrot
at this point.

compiler/compile_target_code.m:
    Delete the compile_csharp_file/8 predicate. It is unused.

compiler/make.module_target.m:
    Abort if we are requested to build a Java or C# foreign code file.
    The only thing that currently makes such requests is compilation of
    fact tables and neither the Java or C# backend supports those.

    Add an explanation of an issue in an XXX.

compiler/link_target_code.m:
    Add an XXX about the MS C# compiler that needs to be investigated.
2025-08-17 20:05:21 +10:00
Zoltan Somogyi
95f3c64561 s/main-module/main_module/ 2025-08-16 00:32:09 +02:00
Zoltan Somogyi
ec0d8ca957 Fill in a large part of "compilation detail".
Minor improvements to the preceding chapters.
2025-08-16 00:30:10 +02:00
Zoltan Somogyi
556e971796 Minor style fix. 2025-08-16 00:24:56 +02:00
Zoltan Somogyi
42d93dbe2f Document the .par grade modifier.
Make minor improvements elsewhere in the user guide.
2025-08-15 16:07:43 +02:00