[m-rev.] for post-commit review: fix mantis bug 437

Peter Wang novalazy at gmail.com
Sun Aug 6 15:28:00 AEST 2017


On Sat, 05 Aug 2017 18:48:48 +0200 (CEST), "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> For post-commit review by Peter, since he reported the bug.

Thanks, Zoltan.

The reference manual is unclear whether a sub-module item sequence
containing zero or more ':- interface.' or ':- implementation.'
declarations only counts as including an interface section or an
implementation section, and thus _declares_ or _defines_ that sub-module.

The compiler currently requires some other item in the sequence otherwise
it treats it as an "empty sub-module" that conflicts with any other item
sequence for that sub-module (perhaps it counts as BOTH declaring and
defining the sub-module?)

A couple of counter-intuitive test cases:

    /*
    empty11.m:111: Warning: submodule `empty11.sub_nonempty_int_empty_imp' of
    empty11.m:111:   module `empty11' is empty.
    empty11.m:111: In module `empty11':
    empty11.m:111:   error: the empty nested submodule
    empty11.m:111:   `empty11.sub_nonempty_int_empty_imp' is a duplicate of a
    empty11.m:111:   previous declaration of that module.
    empty11.m:106:   That previous declaration was here.
    */

    :- module sub_nonempty_int_empty_imp.
    :- interface.
    :- type t ---> t.
    :- end_module sub_nonempty_int_empty_imp.

    :- module sub_nonempty_int_empty_imp.
    :- implementation.
    :- end_module sub_nonempty_int_empty_imp.

and:

    /*
    empty11.m:075: Warning: submodule `empty11.sub_empty_int_nonempty_imp' of
    empty11.m:075:   module `empty11' is empty.
    empty11.m:079: Submodule `empty11.sub_empty_int_nonempty_imp' is missing its
    empty11.m:079:   interface section.
    empty11.m:079: Warning: submodule `empty11.sub_empty_int_nonempty_imp' of
    empty11.m:079:   module `empty11' duplicates an empty submodule.
    empty11.m:075:   This is the location of the empty submodule,
    */

    :- module sub_empty_int_nonempty_imp.
    :- interface.
    :- end_module sub_empty_int_nonempty_imp.

    :- module sub_empty_int_nonempty_imp.
    :- implementation.
    :- type t ---> t.
    :- end_module sub_empty_int_nonempty_imp.


I think it might be best if ':- interface.' always counts as declaring
the sub-module and ':- implementation.' always counts as defining the
sub-module. Completely empty sub-module item sequences could count as
declaring the sub-module so that we don't need to introduce a third thing.

It's not really important, of course.

Peter


More information about the reviews mailing list