Commit Graph

25219 Commits

Author SHA1 Message Date
Julien Fischer
b47a0189e0 Fix errors in the reference manual.
doc/mercury_reference_manual.texi:
    Fix grammar in a number of spots.

    Fix errors in some examples.

    Fix the table mapping Mercury to CLI and C# types.
    There is no System.{Int8,UInt8} in the CLI; they should be
    System.SByte and System.Byte respectively.
2026-04-10 23:42:31 +10:00
Julien Fischer
77c95ee27a Avoid unnecessary module qualification.
library/thread.channel.m:
    As above.
2026-04-10 22:59:03 +10:00
Julien Fischer
50f685ce06 Improve tests for converting durations to and from strings.
Add more systematic tests of conversion of durations to and from strings.

Fix two bugs in duration_from_string/2 identified as a result of the new
tests. The first is that the duration string "P" was incorrectly accepted as
the zero duration; the second is that a fractional seconds component with no
whole number part (e.g. "PT.5S"), was incorrectly accepted.

library/calendar.m:
    Fix the two bugs above.

tests/hard_coded/Mmakefile:
tests/hard_coded/calendar_duration_conv.{m,exp}:
    Add the new test.
2026-04-08 22:26:47 +10:00
Julien Fischer
2537f8826e Fix spelling.
tests/hard_coded/fold_days.m:
    As above.
2026-04-07 16:31:41 +10:00
Julien Fischer
942e98916f Extend the fold_days test.
tests/hard_coded/fold_days.m:
    Add some addition tests of foldl_days.

    Add a test for each of foldl2_days and foldl3_days.

tests/hard_coded/fold_days.exp:
     Conform to the above additions.
2026-04-07 16:28:43 +10:00
Julien Fischer
e1d07359f9 Fix formatting.
tests/hard_coded/calendar_basics.m:
    As above.
2026-04-07 12:04:47 +10:00
Julien Fischer
ad3b88bee1 Add further calendar tests.
tests/hard_coded/calendar_basics.{m,exp}:
    Add tests of current_{local,utc}_time/3.

    Fix spelling a spot.
2026-04-07 11:59:00 +10:00
Julien Fischer
00931a9c84 Fix incorrect comments.
tests/hard_coded/calendar_basics.m:
    As above.
2026-04-07 11:07:27 +10:00
Julien Fischer
bc89fe7fc9 Improve tests for converting date_times to and from strings.
Currently, testing of conversion of date_times to and from strings is only done
by the hard_coded/calendar_test test case.  This testing is only done indirectly
as part of testing other functionality and, in particular, does *not* cover the
failure paths of the string to date_time conversion. Add a new test case that
tests the date_time conversions more thoroughly.

tests/hard_coded/Mmakefile:
tests/hard_coded/calendar_date_time_conv.{m,exp}:
    Add the new test case.
2026-04-07 10:59:13 +10:00
Zoltan Somogyi
d451d8aca5 Simplify the error_spec type.
compiler/error_spec.m:
    Delete the function symbol of the error_msg_component type
    that allowed the inclusion of help text *if* an option had a given value.
    This functionality has been unused since we made all warning and
    informational error_specs conditional on an option.

    Delete the subtype whose only job was to rule out the now-deleted
    function symbol.

    Add a comment about a possible solution of a have-your-cake-AND-eat-it
    problem.

compiler/error_sort.m:
compiler/error_util.m:
compiler/write_error_spec.m:
    Conform to the change in error_spec.m.
2026-04-06 10:35:59 +10:00
Zoltan Somogyi
04d1406c99 Replace error flags with the list of errors themselves.
This is another move towards making it impossible for the compiler
to stop due to the presence of an error *without* printing a diagnostic
about that error.

compiler/grab_modules.m:
    Some of the errors that this module are intended to block the compiler
    from continuing on to semantic analysis, and some are not. We used
    to make the distinction by returning a flag saying "some of these
    are blocking errors", but the list of diagnostics that contained
    these blocking errors

    - contained a list of error_specs reporting *both* kinds of errors, and
    - was not returned alongside the flag, but instead hidden inside
      the module baggage, making it hard to find, and easy to ignore.

    Change this to computing two lists of error_specs: one for blocking errors,
    and one for nonblocking ones. Return the former explicitly, keeping the
    latter in the baggage. This design lets the code that stops execution
    before semantic analysis to test for the list of blocking errors
    being non-empty, which makes printing them the easy thing to do.

    Delete the code that, with --very-verbose, wrote out any error_specs
    we generated during the processing of a .opt or .trans_opt file
    immediately after that processing. The reason is that

    - if we print those error_specs out and then do not return them
      to mercury_compile_make_hlds.m, then mercury_compile_make_hlds.m
      will be making decisions on incomplete and therefore incorrect data,
      while

    - if we print those error_specs out and *also* return them, then

      - either those diagnostics will be printed twice, or
      - we need to implement a new system whereby write_error_spec.m
        keeps a database of the diagnostics it has already printed,
        and simply skips printing any repeats.

    Neither of those alternative is palatable, and since in several
    decades, I have never needed such immediate printing of diagnostics,
    losing that capability is not really an issue.

    Fix some relics of the era when the data structures that were
    module_baggage's predecessors could not distinguish between fatal
    and nonfatal errors.

compiler/mercury_compile_make_hlds.m:
    For now, make the new code in grab_modules.m work with the existing
    decision making code. Changing that is future work, since it requires
    changes to other compiler components as well.
2026-04-06 05:09:01 +10:00
Julien Fischer
9e8153b5a6 Fix typos in recent change.
tests/hard_coded/calender_basics.m:
    Adjust two JDN's that were off by one.

tests/hard_coded/calendar_basics.exp:
    Conform to the above change.
2026-04-05 12:31:29 +10:00
Zoltan Somogyi
291b5186f7 Direct stderr to the same stream as stdout in bootchecks. 2026-04-05 12:12:07 +10:00
Zoltan Somogyi
f5c542af63 Fix the failure of tests/valid/tuple_eqv.
The long-existing possible option incompatibility was exposed
by recent changes.
2026-04-05 08:08:47 +10:00
Zoltan Somogyi
d631c0bb22 Avoid compiler crashes with --optimize-saved-vars. 2026-04-05 02:53:05 +10:00
Zoltan Somogyi
7e8781390d Turn a set of clauses into an explicit disjunction. 2026-04-05 02:52:19 +10:00
Julien Fischer
57582b6527 Add more calendar tests.
tests/hard_coded/calendar_basics.{m,exp}:
    As above.
2026-04-03 21:43:06 +11:00
Zoltan Somogyi
a14544b7e7 Rationalize the code expanding @file cmd line args.
compiler/mercury_compile_args.m:
    Instead of writing out any error messages (and setting the exit status)
    in different ways in different circumstances, return all error messages
    to our caller, as error_specs, and the option_table needed to print
    those error_specs out.

    Simplify the code that actually does the expansion of @file arguments,
    both by invoking higher level primitives than were available when
    the original code was written, and by avoiding repeatedly putting
    arguments info ok/1 wrappers and taking them out again.

    Change the argument list of setup_all_args to delete the ErrorStream
    argument and pass only ProgressStream, because its only caller always
    passes the *same* stream as both arguments.

compiler/mercury_compile_main.m:
    Print the error messages that mercury_compile_args.m now returns.
    Standardize on printing "mmc:" before those messages to identify
    the program reporting those errors. (The old code could print any
    one of "mercury_compile:", "mmc:", the name of the executable,
    or nothing.)

compiler/file_util.m:
    Add two utility functions for the new code in mercury_compile_args.m.

compiler/handle_options.m:
    Add an XXX.

tests/invalid/invalid_mllibs.err_exp:
tests/invalid_make_int/bad_color.int_err_exp:
tests/invalid_options_file/inf_incl_direct.err_exp:
tests/invalid_options_file/inf_incl_indirect.err_exp:
tests/invalid_options_file/no_assign.err_exp:
tests/invalid_options_file/no_var.err_exp:
tests/invalid_options_file/nonexistent_file.err_exp:
tests/invalid_options_file/undefined_var.err_exp:
tests/invalid_options_file/unterminated_string.err_exp:
tests/invalid_options_file/unterminated_var.err_exp:
    Consistently expect the "mmc:" prefix before the error messages
    now printed by mercury_compile_main.m.
2026-04-03 07:06:46 +11:00
Zoltan Somogyi
47e7b8eedd Reduce the number of modules that set the exit status ...
... by removing four more modules from that set.

compiler/make.module_dep_file.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_middle_passes.m:
    Replace bespoke error reporting code with invocations of standardized
    error reporting predicates.

compiler/source_file_map.m:
    Delete an unused predicate.
2026-04-03 04:16:56 +11:00
Zoltan Somogyi
6c50482539 Use separate loops for error and non-error cases. 2026-04-03 03:20:17 +11:00
Zoltan Somogyi
d067ea1255 Reduce the number of modules that set the exit status ...
... by removing globals.m, handle_options.m recompilation.used_file.m
from that set.

compiler/globals.m:
compiler/recompilation.used_file.m:
    Replace bespoke error reporting code with invocations of standardized
    error reporting predicates.

compiler/handle_options.m:
    Generate error_specs instead of writing out warnings directly.
2026-04-03 01:26:37 +11:00
Zoltan Somogyi
914402bea3 Put some predicates into top-down order. 2026-04-03 00:30:57 +11:00
Zoltan Somogyi
4717fac160 Simplify the internals of file_util.m. 2026-04-03 00:29:34 +11:00
Zoltan Somogyi
2d6c0ff87c Fix indentation. 2026-04-02 23:22:02 +11:00
Zoltan Somogyi
e00722533b Reduce the number of modules that set the exit status ...
... by removing export.m and options_file.m from that set.

compiler/export.m:
compiler/options_file.m:
    Replace bespoke error reporting code with invocations of standardized
    error reporting predicates.

compiler/file_util.m:
    Add versions of existing error reporting predicates and functions that
    work without access to a globals structure, for use by options_file.m.
2026-04-02 23:17:58 +11:00
Julien Fischer
497288a2f9 Minor fixes for extras/lex.
extras/lex/lex.m:
extras/lex/regex.m:
    Fix comments.

extras/lex/lex.convert_NFA_to_DFA.m:
    Fix formatting.
2026-04-02 21:58:15 +11:00
Zoltan Somogyi
f79d98fd45 Fix indentation. 2026-04-02 21:12:54 +11:00
Zoltan Somogyi
6e468a5110 Reduce the number of modules that set the exit status ...
... by removing compiler_util.m from that set.

compiler/tupling.m:
    Replace the only two calls to report_warning with code to return
    error_specs.

compiler/mercury_compile_middle_passes.m:
    Accumulate the resulting error_specs.

compiler/write_error_spec.m:
    Inline the only call to record_warning_opt_table.

compiler/compiler_util.m:
    Delete report_warning and record_warning_opt_table, which now have
    no callers, and record_warning, which had no callers to begin with.
2026-04-02 20:55:38 +11:00
Julien Fischer
d22107db4f Fix some copy-and-paste errors.
samples/c_interface/c_calls_mercury/c_main.c:
samples/c_interfcae/simpler_c_calls_mercury/main.c:
    As above.
2026-03-31 10:17:27 +11:00
Julien Fischer
df1955508b Fix typo.
samples/concurrency/midimon/concurrent_stream.m:
    As above.
2026-03-31 10:09:14 +11:00
Julien Fischer
cdf10e673c More minor fixes for samples.
samples/c_interface/short_example.m:
    Do not output two trailing newlines.

samples/concurrency/midimon/concurrent_stream.m:
    Module qualify some calls.

samples/java_interface/short_example.m:
    s/JAva/Java/

samples/muz/muz.m:
    Fix some spelling errors.
2026-03-31 00:00:27 +11:00
Julien Fischer
f23c555003 Update programming style and fix errors in samples.
samples/concurrency/dining_philosophers/philo.m:
    Add a module qualifier.

samples/eliza.m:
    Fix a copy-and-paste error.

samples/lazy_list/lazy_list.m:
samples/lazy_list/lazy_list_test.m:
    Update programming style.
2026-03-30 21:51:16 +11:00
Julien Fischer
7c2099f627 Minor fixes for samples.
samples/calculator2.m:
    Do not output error messages that begin with "unexpected unexpected".

samples/sort.m:
    Fix inadvertently escaped newline in usage message.

samples/ultra_sub.m:
    Fix inverted arguments in usage message.
2026-03-30 16:27:29 +11:00
Julien Fischer
15b54f5377 Use C99 conversion specifiers in the runtime.
C99 introduced additional conversion specifiers for use with the printf and
scanf family of functions. Specifically, the 'z' size specifier for size_t
values and the 't' size specifier for ptrdiff_t values. Historically, we have
not used them because the C99 support in a certain C compiler was lacking.
Since this is no longer the case, use them. This removes the need of a bunch
of casts, some of which were incorrect on 64-bit Windows.

runtime/mercury_accurate_gc.c:
runtime/mercury_memory_zones.c:
runtime/mercury_stacks.c:
runtime/mercury_wrapper.c:
    As above.
2026-03-29 03:29:34 +11:00
Julien Fischer
07abdbd6e4 Extend the documentation of calender.same_date/2.
library/calender.m:
    In particular, add a reminder that the results are only meaningful if the
    two arguments are date_times in the same time zone.
2026-03-29 01:21:45 +11:00
Julien Fischer
8ece998041 Minor documentation fix.
library/calendar.m:
    s/date/date_time/ in a spot.
2026-03-28 22:44:16 +11:00
Zoltan Somogyi
600393c7e7 Describe calendar.m's changes in more detail. 2026-03-28 22:10:19 +11:00
Julien Fischer
d3a2c9fde7 Another calendar documentation fix.
library/calender.m:
    As above.
2026-03-28 17:11:59 +11:00
Julien Fischer
cbce56f173 Fix and update calendar documentation.
library/calender.m:
    As above.
2026-03-28 17:11:11 +11:00
Julien Fischer
1f333c07db Clarify the relationship between date_times and time zones.
library/calender.m:
    As above.
2026-03-28 17:01:19 +11:00
Julien Fischer
f57e5c8745 Rename date/0 to date_time/0.
The date/0 type is misnamed. Values of the type have both a date and a time
component. The common name for combined date and time values is a "date_time",
for which we have had a type synonym since 2014. This change makes date_time
the proper name for type and make date into the type synonym.

Deprecate the date/0 name and note that we will change its meaning in a future
release. (It will eventually be used for data values that do not have a time
component.)

Rename predicates and functions accordingly and mark the existing versions as
obsolete.

library/calendar.m:
    Make the above renamings.

library/hard_coded/stream.string_writer.m:
    Replace a call to a now obsolete function.

NEWS.md:
    Add entry describing the above.

tests/hard_coded/calendar_init_date.{m,exp}:
tests/hard_coded/calendar_test.m:
tests/hard_coded/fold_days.m:
tests/hard_coded/stream_string_writer_types.m:
     Conform to the above changes.
2026-03-28 14:56:10 +11:00
Julien Fischer
0e7baba9d6 Delete an unused variable.
runtime/mercury_wrapper.c:
    As above.
2026-03-27 20:46:24 +11:00
Julien Fischer
0d9b0c970a Fix a runtime error message.
runtime/mercury_wrapper.c:
    Add a missing space to an error message.
2026-03-27 20:41:29 +11:00
Julien Fischer
7966692d87 Fix copy-and-paste error.
runtime/mercury_hash_table.c:
     As above.
2026-03-27 20:31:33 +11:00
Julien Fischer
50ac3a9e66 Do not install low-level C parallel grades by default.
configure.ac:
compiler/handle_options.m:
     As above.
2026-03-27 12:28:31 +11:00
Zoltan Somogyi
bbb93b6eab Disable LLDS .par grades until its bug is fixed. 2026-03-26 22:39:15 +11:00
Zoltan Somogyi
9abf70bf16 Improve debuggability and style in cse_detection.m. 2026-03-26 16:54:25 +11:00
Zoltan Somogyi
5b74acdea0 Build flat conjunctions. 2026-03-21 20:47:35 +11:00
Zoltan Somogyi
ab4af128e0 Factor out common code. 2026-03-21 09:02:24 +11:00
Zoltan Somogyi
f4453ae9ae Improve leap year testing code. 2026-03-21 09:02:04 +11:00