Commit Graph

25195 Commits

Author SHA1 Message Date
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
Julien Fischer
e5b2bb40eb Add is_leap_year/1 and days_in_month/2.
Add a predicate to the calendar module for testing if a year is a leap year.
Use a more efficient method for determining this than the existing code
in the implementation of this module used (and replace that code with
a call to the new predicate).

Add the function days_to_month/2, which is a strongly typed wrapper
for the implementation function max_day_in_month_for/2.

Add a new test case covering basic operations in the calendar module,
together with the newly added operations.

library/calendar.m:
    As above.

NEWS.md:
    Announce the new additions.

tests/hard_coded/Mmakefile:
tests/hard_coded/calendar_basics.{m,exp}:
    Add the new test case.
2026-03-20 21:39:23 +11:00
Julien Fischer
5a6a19b46e Fix a copy-and-paste error.
library/string.m:
    The documentation comment for to_uppercase gives the conversion range for
    to_lowercase.
2026-03-20 20:47:39 +11:00
Zoltan Somogyi
b2049fdc99 Add cord.ulength. 2026-03-19 18:31:05 +11:00
Julien Fischer
9b0f173b22 Fix some documentation errors in the calendar module.
librayr/calendar.m:
   As above.
2026-03-18 16:16:45 +11:00
Julien Fischer
fbe6450d4b Fix indentation.
library/rtree.m:
   As above.
2026-03-18 15:59:04 +11:00
Julien Fischer
76a0cf88b8 Fix inverted arguments.
library/rtree.m:
   As above.
2026-03-18 15:55:12 +11:00
Zoltan Somogyi
d448b1cfa0 Document the reason for four-year dates. 2026-03-17 17:51:46 +11:00
Zoltan Somogyi
8b0cea125e Replace bespoke make rules with existing implicit rule.
tests/debugger/Mmakefile:
    Delete the bespoke make rules for test cases that do not require
    their own special handling.

tests/debugger/all_solutions.exp:
tests/debugger/all_solutions.exp2:
tests/debugger/all_solutions.exp4:
tests/debugger/browse_packed.exp:
tests/debugger/browse_pretty.exp:
tests/debugger/class_decl.exp:
tests/debugger/cmd_quote.exp:
tests/debugger/debugger_regs.exp:
tests/debugger/field_names.exp:
tests/debugger/implied_instance.exp:
tests/debugger/label_layout.exp:
tests/debugger/list_cmd.exp:
tests/debugger/lval_desc_array.exp:
tests/debugger/multi_parameter.exp:
tests/debugger/multi_parameter.exp2:
tests/debugger/mutrec.exp:
tests/debugger/no_inline_builtins.exp:
tests/debugger/queens_rep.exp:
tests/debugger/shallow.exp:
tests/debugger/shallow.exp2:
    Expect standardized event numbers and call sequence numbers,
    since that is what the implicit rule specifies.

tests/debugger/all_solutions.m:
    Fill in missing info about which .expN file is for what situations.
2026-03-15 13:07:48 +11:00
Julien Fischer
a83ba5ee79 Modernise the header comment in the float module.
library/float.m:
     Remove out-of-date references to ANSI C, POSIX, C9X (C99), and
     platform-specific behaviour on Linux, Digital Unix and Solaris.

     All current Mercury backends use (and are _required_ to use) IEEE floating
     point; delete conditional language about this.

     Do not specify halting with runtime error as a resolution for NaNs or
     signed zeros; instead just say we should throw an exception.

     Generalise the discussion of excess precision.
     (XXX ideally we could get rid of this by telling C compilers not to
     use extended-precision FP registers on those system that provide
     them; most of them do that by default anyway, but I'm not sure if
     all of them do.)
2026-03-14 17:09:55 +11:00
Zoltan Somogyi
b97ae63fcc Improve the documentation of the calendar module. 2026-03-14 15:57:40 +11:00
Zoltan Somogyi
de1e7ce86d Factor out many rules into one implicit rule.
Delete parts of an action that are needed only on machines running OSF-1.

Delete parts of an action that have been obsolete since we switched
to '.' as the module qualifier character decades ago.
2026-03-14 12:14:47 +11:00
Nadia Yvette Chambers
fa271a0ec8 Fix integer.mul_by_digit producing denormalized zeros. (#141)
mul_by_digit(0, Y) produced i(Len, [0, 0, ...]) instead of the
canonical integer.zero = i(0, []). Since is_zero/1 only matched
the canonical form, denormalized zeros were silently treated as
nonzero, causing incorrect results in rational.m (e.g., gcd_2
non-termination, division-by-zero crashes in big_quot_rem).

Three fixes applied:
- Guard mul_by_digit and printbase_mul_by_digit to return
  integer.zero when the digit is 0 (root cause fix).
- Make is_zero/1 recognize denormalized all-zero digit lists
  as defense in depth.
- Replace structural `= integer.zero` checks in rational.m
  with integer.is_zero/1 calls for robustness.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 09:35:20 +11:00
Zoltan Somogyi
b2f1ff63df Stop using := assignments.
tests/debugger/Mmakefile:
    Instead, define each make variable exactly once on each possible
    path through the relevant nested conditionals.
2026-03-14 05:08:41 +11:00
Julien Fischer
f65cf12e94 Add some missing semicolons.
library/dir.m:
    Add some missing semicolons to some statements in foreign_proc body.
    (The code in question compiled because we wrap foreign proc bodies
    int { ;}.)
2026-03-14 01:59:56 +11:00
Julien Fischer
147b290bd2 Fix minor problems in some READMEs.
Documentation/README.CSharp.md:
Documentation/README.Java.md:
Documentation/README.MSYS2.md:
    As above.
2026-03-14 00:27:27 +11:00
Julien Fischer
048149773b Minor fixes for reference manual.
doc/mercury_reference_manual.texi:
    Fix inverted characters.

    Fix incorrect variable names in examples and the description
    of the DCG transformation.

    Fix an incorrect Java foreign_proc example.

    Fix the example of higher-order impure code; it would not
    compile as written.
2026-03-13 22:14:57 +11:00
Julien Fischer
af203adf5d Improve the documentation of the calendar module.
library/calendar.m:
    Reword the module header to mention microsecond resolution.

    Reword the description of the leap year rule in the header.

    Document the failure conditions of init_date/8, date_from_string/2
    and duration_from_string/2. Mention that date_from_string/2 accepts
    negative years, years with more than four digits, and fractional
    seconds with between one and six digits.

    Document that date_to_string/1 can produce negative years in its
    output.

    Document the microsecond and timezone limitations of
    current_local_time/3 and current_utc_time/3.

    Expand the documentation of julian_day_number/1 to explain what
    a Julian day number is.

    Expand the documentation of the duration type to cover sign constraints,
    clamping behaviour, the treatment of leap seconds, internal normalisation
    rules, and the relationship between init_duration/7 arguments and component
    access function return values.

    Document the ranges returned by the duration component access functions for
    both positive and negative durations.

    Document the sign constraint and exception behaviour of init_duration/7.

    Expand the documentation of duration_from_string/2 to cover
    negative durations, the six-digit fractional seconds limit,
    and the normalisation round-trip example.

    Rewrite the documentation of duration/2 to describe the
    non-invertibility of duration/2 and add_duration/3 more concisely.

    Simplify the documentation of foldl_days/5.

    Various other minor documentation and formatting changes.
2026-03-13 20:08:25 +11:00
Julien Fischer
526ede3f75 Extend a calendar test.
tests/hard_coded/calendar_test.{m,exp}:
    Add further tests of end of month day clamping.

tests/hard_coded/calendar_init_data.m:
    Fix typo.
2026-03-13 17:02:12 +11:00
Zoltan Somogyi
953ea7667f Fix deconstructing direct args.
The crash that this diff fixes occurred when giving a command such as
"print Var^1" to mdb, where the first argument of Var is a direct arg.

runtime/mercury_ml_expand_body.h:
    When deconstructing a term with a direct arg, return NULL
    as the value of expand_info->chosen_arg_word_sized_ptr.
    The crash occurred when we returned a non-null pointer,
    which violated the expectations of trace/mercury_trace_vars.c
    and its callers. (Not surprising, since those that function and
    its callers were written long before the direct_arg optimization
    was added to the system.)

runtime/mercury_deconstruct.h:
    Document the rationale behind the above changes. (The contents of
    mercury_ml_expand_body.h are #included in mercury_deconstruct.c.)

trace/mercury_trace_vars.c:
    Add the debugging code I used to track down this issue, in disabled form.

    Fix missing copyright year.

trace/mercury_trace_browse.c:
    Delete obsolete comment.

    Fix missing copyright years.

tests/debugger/direct_arg_test.{m,inp,exp}:
    A test case for this bug.

tests/debugger/Mmakefile:
    Enable the new test case.

compiler/hlds_out_type_table.m:
    When dumping out the data constructors in the type table,
    if a constructor has names for some of its fields,
    put the name and the type of each field on different lines.
    In the original test case for this bug, of which direct_arg_test.m
    is an extreme simplification, pretty much every line overflows
    without this.

    Also, factor out some duplicated code, and replace bools with values
    of a bespoke type.
2026-03-13 14:50:15 +11:00
Julien Fischer
a19bb893e4 Add a missing comma.
library/string.m:
    As above.
2026-03-13 14:47:28 +11:00
Julien Fischer
1348c558fd Fix omission in documentation of io.set_output_line_number.
library/io.m:
    Document that the arity-4 version affect the specified output stream.
2026-03-13 14:18:03 +11:00
Julien Fischer
d88d652d07 Fix a bug in io.set_line_number/3.
Due to a copy-and-paste error introduced in commit 05fd615471,
set_line_number/2 was incorrectly setting the line number of the
current output stream, not the current input stream.

library/io.m:
    Fix the above bug.

tests/hard_coded/Mmakefile:
tests/hard_coded/bad_set_line_number.{m,exp}:
    Add a regression test.
2026-03-13 14:08:01 +11:00
Julien Fischer
6590da7052 Delete an extraneous space.
library/list.m:
    As above.
2026-03-13 12:44:54 +11:00
Zoltan Somogyi
4030e8372a Announce --warn-unused-types. 2026-03-12 07:46:17 +11:00