[m-rev.] for review: --warn-unsorted-import-blocks

Julien Fischer jfischer at opturion.com
Tue Jan 21 14:26:59 AEDT 2025


On Tue, 21 Jan 2025 at 07:53, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:

> Add a new option, --warn-unsorted-import-blocks.
>
> compiler/options.m:
> doc/user_guide.texi:
> NEWS.md:
>     Add, document and announce the new option. It is off by default,
>     but of course I tested its behavior when turned on. Most of this
>     diff deals with the consequences.
>
> compiler/item_util.m:
>     Add code to generate the new warnings if requested.
>
> compiler/convert_parse_tree.m:
>     Request the new warning if the new option is set when processing
>     source files..

Delete the second full stop there.

...

> diff --git a/NEWS.md b/NEWS.md
> index 2a38c5972..00ff7e7be 100644
> --- a/NEWS.md
> +++ b/NEWS.md
> @@ -1451,6 +1451,18 @@ Changes to the Mercury compiler
>    and that functions that compute a value only in some circumstances
>    (i.e. partial functions) be expressed as predicates instead.
>
> +* We have added a new option `--warn-unsorted-import-blocks`. If the user
> +  specifies this option, the compiler will generate a warning if any line
> +  contains `import_module` or `use_module` declarations for more than one
> +  module, or if a block of such declarations on consecutive lines
> +  are not sorted on module name.
> +
> +  The discipline enforced by this option can standardize the appearance
> +  of the sections of Mercury module containing these declarations, make

s/module/modules/

> +  diffs of changes to these sections easier to read, and spare programmers
> +  from having to decide on a case-by-case basis exactly where they want
> +  to add a new `import_module` or `use_module` declaration.
> +
>  * The deprecated option `--trail-segments` has been deleted and the grade
>    component `trseg` is no longer accepted as a synonym for `tr`.

That looks fine otherwise.

Julien.


More information about the reviews mailing list