Files
mercury/tests/invalid/ee_invalid.err_exp
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

56 lines
3.0 KiB
Plaintext

ee_invalid.m:039: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:039: `int'/0:
ee_invalid.m:039: error: `int'/0 is a builtin type.
ee_invalid.m:043: In `:- pragma foreign_export_enum' declaration:
ee_invalid.m:043: error: undefined type `undefined_type'/0.
ee_invalid.m:047: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:047: `ee_invalid.foo'/1:
ee_invalid.m:047: error: `ee_invalid.foo'/1 is not an enumeration type.
ee_invalid.m:047: It has this non-zero arity constructor:
ee_invalid.m:047: `foo'/1.
ee_invalid.m:051: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:051: `ee_invalid.bar'/0:
ee_invalid.m:051: error: `ee_invalid.bar'/0 is not an enumeration type; it is
ee_invalid.m:051: an equivalence type.
ee_invalid.m:058: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:058: `ee_invalid.baz'/0:
ee_invalid.m:058: error: `ee_invalid.baz'/0 is not an enumeration type; it is
ee_invalid.m:058: a foreign type.
ee_invalid.m:063: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:063: `ee_invalid.alphabet'/0:
ee_invalid.m:063: error: the following symbol is not a constructor of the
ee_invalid.m:063: type:
ee_invalid.m:063: `deg'.
ee_invalid.m:068: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:068: `ee_invalid.alphabet'/0:
ee_invalid.m:068: error: the following symbol has a module qualification that
ee_invalid.m:068: is not compatible with the type definition:
ee_invalid.m:068: `foo.def'.
ee_invalid.m:073: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:073: `ee_invalid.alphabet'/0:
ee_invalid.m:073: error: the following symbol is not a constructor of the
ee_invalid.m:073: type:
ee_invalid.m:073: `deg'.
ee_invalid.m:073: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:073: `ee_invalid.alphabet'/0:
ee_invalid.m:073: error: the specified mapping between the names of Mercury
ee_invalid.m:073: constructors and the corresponding foreign names is
ee_invalid.m:073: inconsistent.
ee_invalid.m:073: The following foreign name is repeated:
ee_invalid.m:073: `ABC'.
ee_invalid.m:077: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:077: `ee_invalid.alphabet'/0:
ee_invalid.m:077: error: the specified mapping between the names of Mercury
ee_invalid.m:077: constructors and the corresponding foreign names is
ee_invalid.m:077: inconsistent.
ee_invalid.m:077: The following Mercury constructor name is repeated:
ee_invalid.m:077: `abc'.
ee_invalid.m:083: In `:- pragma foreign_export_enum' declaration for type
ee_invalid.m:083: `ee_invalid.strange_names'/0:
ee_invalid.m:083: error: some of the constructors of the type cannot be
ee_invalid.m:083: converted into valid identifiers for C.
ee_invalid.m:083: The problematic foreign names are:
ee_invalid.m:083: `!@THIS',
ee_invalid.m:083: `#$WON'T',
ee_invalid.m:083: `%^WORK'.