Files
mercury/tests/invalid/undef_impl_def_literal.err_exp
Zoltan Somogyi 4d14d48991 Use an enum to identify impl defined literals.
compiler/prog_data.m:
    Replace the cons_id impl_defined_const(string), where the string
    has only five legal values, with a impl_defined_const() wrapped
    around an enum with those five values. This makes some illegal states
    unrepresentable.

compiler/superhomogeneous.m:
    Make the predicate that converts term.implementation_defined functors
    to cons_ids check for the five legal strings, convert each to its
    enum value, and return an error message instead of a cons_id if the
    string is *not* one of the permitted five.

    Delete the code moved to parse_util.m (see the next entry).

compiler/prog_util.m:
    There was another predicate in prog_util.m that also converted
    term functors to cons_ids, which had to be kept in sync
    with the code in superhomogeneous.m that did the same job.
    The version in prog_util.m, even though it had code to handle
    all term functors, was only ever called from parse_inst_mode_name.m,
    which called it *only* on integer, float and string constants.

    Converting float and string functors to cons_ids is trivial,
    but converting integer functors is not, due to our support for
    ten different kinds of integers. However, instead of updating
    the integer conversion code in both superhomogeneous.m and prog_util.m,
    replace both with a single predicate. Since this predicate does
    a parsing job, and is used only during the construction of the
    initial HLDS, put it in parse_util.m.

compiler/parse_util.m:
    Base this unified predicate on the code that used to be in
    superhomogeneous.m since this is the only one that can generate
    error messages for integer constants that are outside the range
    of their type.

compiler/parse_inst_mode_name.m:
    Conform to the changes above. The code in parse_util.m now generates
    an error message if an integer const in a bound inst is too big
    to be represented by its type, which is much better than the
    compiler abort by the now-deleted code in prog_util.m that such
    code would have resulted in.

compiler/hlds_out_util.m:
compiler/implementation_defined_literals.m:
compiler/mercury_to_mercury.m:
compiler/old_type_constraints.m:
compiler/parse_tree_to_term.m:
compiler/prog_out.m:
compiler/prog_rep.m:
compiler/typecheck.m:
    Conform to the changes above.

tests/invalid/undef_impl_def_literal.err_exp:
    Expect the error message from the new code in superhomogeneous.m
    for $nosuchthing, instead of the generic error message about
    "undefined symbol `$nosuchthing' (which implicitly implies that
    the error could be fixed by *defining* $nosuchthing).
2021-04-01 20:01:11 +11:00

6 lines
325 B
Plaintext

undef_impl_def_literal.m:015: Error: unexpected implementation defined literal
undef_impl_def_literal.m:015: `$nosuchthing'.
undef_impl_def_literal.m:015: The only valid implementation defined literals
undef_impl_def_literal.m:015: are `$line', `$file', `$module', `$pred' and
undef_impl_def_literal.m:015: `$grade'.