Files
mercury/tests/valid/bug457.m
Peter Wang 72bc36afc2 Fix some problems with static terms in LLDS grades.
compiler/unify_gen.m:
    Add type_info, typeclass_info and ground term constants to the var
    state map using assign_const_to_var instead of assign_expr_to_var.
    expr_is_constant will fail if a constant expression is added with
    the more general assign_expr_to_var, causing missed opportunities
    to construct terms statically in var_locn.m.

    Prevents a compiler abort (bug #457) where mark_static_terms.m
    determines that a term can be constructed statically but var_locn.m
    decides otherwise.

compiler/var_locn.m:
    Do not abort if var_locn_assign_dynamic_cell_to_var is passed
    `construct_statically'. Even after the previous change, it is
    possible for mark_static_terms.m to determine that a cell with a
    dummy type argument can be constructed statically but var_locn.m
    currently does not. This was preventing bootchecks at
    -O5 --intermodule-optimization.

compiler/hlds_goal.m:
    Fix misleading documentation for how_to_construct.

tests/valid/Mercury.options:
tests/valid/bug457.m:
    Add a test case.
2018-04-30 09:41:28 +10:00

30 lines
891 B
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% A type_info cell was not constructed statically by var_locn.m.
% It caused a compiler abort because that differed from the
% construct_statically hint set by mark_static_terms.m.
%
%---------------------------------------------------------------------------%
:- module bug457.
:- interface.
:- import_module io.
:- pred wrapper(pred(io, io), io, io).
:- mode wrapper(in(pred(di, uo) is cc_multi), di, uo) is cc_multi.
:- implementation.
:- import_module exception.
wrapper(Pred, !IO) :-
Closure = (pred({}::out, IO0::di, IO::uo) is cc_multi :-
Pred(IO0, IO)
),
try_io(Closure, _TryResult, !IO).
%---------------------------------------------------------------------------%