mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-27 07:14:20 +00:00
compiler/module_imports.m:
Implicitly import stream.m if the module being compiled may call
stream.string_writer.format.
compiler/simplify_proc.m:
Keep stream.put around until format_call.m may need it.
compiler/pred_table.m:
If looking for a predicate fails, generate an error message that mentions
the module name part of the fully qualified predicate name being
looked for.
tests/hard_coded/stream_put_bug.{m,exp}:
New test case, based on one contributed by sebgod (the filer of
Mantis bug 369).
tests/hard_coded/Mmakefile:
Enable the new test case.
36 lines
1017 B
Mathematica
36 lines
1017 B
Mathematica
% vim: ts=4 sw=4 expandtab ft=mercury
|
|
%
|
|
% This is a regression test for Mantis bug #369.
|
|
%
|
|
% The bugs were that (a) for a module like this one, which calls
|
|
% stream.string_writer.format but does not *explicitly* import stream.m,
|
|
% the compiler did not *implicitly* import stream.m, and (b) it also
|
|
% did not protect stream.put from being deleted by dead predicate elimination.
|
|
|
|
:- module stream_put_bug.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- interface.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module list.
|
|
:- import_module string.
|
|
:- use_module stream.string_writer.
|
|
:- use_module string.builder.
|
|
|
|
main(!IO) :-
|
|
some [!State] (
|
|
!:State = string.builder.init,
|
|
stream.string_writer.format(string.builder.handle,
|
|
"answer to life universe everything %d\n", [i(42)], !State),
|
|
stream.string_writer.format(string.builder.handle,
|
|
"bug %s\n", [s("not present")], !State),
|
|
io.write_string(string.builder.to_string(!.State), !IO)
|
|
).
|