Commit Graph

3 Commits

Author SHA1 Message Date
Zoltan Somogyi
ffa87fc0d9 Update the programming style of some tests in invalid.
tests/invalid/bug10.{m,err_exp}:
tests/invalid/bug115.{m,err_exp}:
tests/invalid/bug117.{m,err_exp}:
tests/invalid/bug191.{m,err_exp}:
tests/invalid/bug436.{m,err_exp}:
tests/invalid/invalid_binary_literal.{m,err_exp}:
tests/invalid/invalid_decimal_literal.{m,err_exp}:
tests/invalid/invalid_float_literal.{m,err_exp}:
tests/invalid/invalid_hex_literal.{m,err_exp}:
tests/invalid/invalid_octal_literal.{m,err_exp}:
tests/invalid/invalid_pragma.{m,err_exp}:
tests/invalid/require_tailrec_invalid.{m,err_exp}:
tests/invalid/type_lhs_var.{m,err_exp}:
tests/invalid/typeclass_no_param.{m,err_exp}:
tests/invalid/unrecognized_pragma.{m,err_exp}:
    Put vim modelines into these .m files, and improve their
    programming style.

    Update the .err_exp files for the changed line numbers.
2019-07-25 21:42:21 +02:00
Zoltan Somogyi
7e93bbd325 Use the same code for foreign{_export,}_enums where possible.
compiler/add_foreign_enum.m:
    The biggest part of processing both foreign_enums and foreign_export_enums
    is validating the mapping from the Mercury names of the enum's constants
    to the string giving their user-chosen tag values (for foreign_enums)
    or to the string naming the foreign language variable to which their
    compiler chosen tag values should be assigned. There is a difference
    (the mapping must mention all constants in the type only for
    foreign_enums), but it is minor.

    We nevetheless used to use completely separate code for validating
    the maps, and for other related tasks (such as checking that the type
    consists *only* of constants) for the two pragmas. Change this, and use
    the same code for validation, with some minor parameterization.
    This also allows us to use the same, or closely related, error messages
    for the kinds of errors that can occur in both kinds of pragmas.

    Change the wording of those error messages to talk about mappings being
    "inconsistent", as opposed to them "not being a bijection", since the
    latter terminology will be unfamiliar to some Mercury users.

tests/invalid/bug436.err_exp:
    Expect the list of incorrectly-mentioned constants in the order of their
    appearance (which also happens to be their sorted order, in this case),
    since the code that generates the error message now preserves the order
    from the pragma.

tests/invalid/ee_invalid.err_exp:
    Expect the "inconsistent" wording for two error messages.

tests/invalid/foreign_enum_invalid.err_exp:
    Expect the "inconsistent" wording for two error messages,
    and expect the *reasons* for the inconsistency to be listed also,
    since we now generate this information for foreign_enums as well
    (not just for foreign_export_enums, as before).
2018-02-27 01:57:24 +11:00
Julien Fischer
c40f4300f7 Fix bug #436.
Fix a bug in foreign_enum pragmas where the compiler was not checking if
symbols appearing in the third argument were actually constructors of the type
that is the subject of the pragma.  Such symbols would be silently ignored.

compiler/add_foreign_enum.m:
     Generate an error message if we encounter symbols in the third argument
     of a foreign_enum pragma that are not constructors of the type.

tests/invalid/Mmakefile:
tests/invalid/bug436.{m,err_exp}:
     Add a regression test for bug #436.

tests/invalid/fe_unmapped_nonverbose.{m,err_exp}:
tests/invalid/fe_unmapped_verbose.{m,err_exp}:
     Fix a misspelled constructor name in these tests.
2017-05-03 09:45:17 +10:00