Files
mercury/tests/valid/bug159.m
Zoltan Somogyi fdd141bf77 Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the tests
    that check compiler error messages, expect the new line numbers.

browser/cterm.m:
browser/tree234_cc.m:
    Import only one module per line.

tests/hard_coded/boyer.m:
    Fix something I missed.
2015-02-16 12:32:18 +11:00

51 lines
1.4 KiB
Mathematica

% vim: ts=4 sw=4 et ft=mercury
%
% This is a test case for Mantis bug 159. The bug was that mode checking and
% unique mode checking did not eliminate a from_ground_term scope that
% constructed a variable which was unused except for its type (variable L
% in pickles/0 below), even though they eliminated construction unifications
% that constructed similarly unused variables.
:- module bug159.
:- interface.
:- type pickles ---> pickles(int).
:- func pickles = pickles.
:- implementation.
:- import_module int.
:- import_module list.
:- import_module univ.
:- import_module type_desc.
:- import_module construct.
:- import_module deconstruct.
:- import_module require.
:- pragma memo(pickles/0).
pickles = !:P :-
!:P = pickles(0),
% The size of this term should be (and currently is) above the
% from_ground_term threshold.
L = [1, 2, 3],
register_pickle(type_ctor(type_of(L)), pickle_list_as_array, !P).
:- type byte_buffer == int.
:- type maybe_pickle == pred(pickles, univ, byte_buffer, byte_buffer).
:- inst maybe_pickle == (pred(in, in, di, uo) is det).
:- pred register_pickle(type_ctor_desc::in, maybe_pickle::in(maybe_pickle),
pickles::in, pickles::out) is det.
register_pickle(_T, _N, pickles(I), pickles(I+1)) :-
true.
:- pred pickle_list_as_array `with_type` maybe_pickle `with_inst` maybe_pickle.
pickle_list_as_array(_Pickles, _UnivList, !BB) :-
error("foo").