[m-rev.] for review: fix failure of debugger/tailrec1

Julien Fischer jfischer at opturion.com
Thu Jun 26 13:15:07 AEST 2025


For review by anyone.

I recall there being a question raised sometime ago about whether
foreign_import_module
pragmas also required an :- import_module or :- use_module declaration
for the same
imported module to be present?  Was there ever a definitive answer to this?
(This test case is one where the foreign import is necessary, but none
of the Mercury
code requires io.primitives_read to be imported.)

---------------------------------------------

Fix failure of debugger/tailrec1.

tests/debugger/tailrec1.m:
     Foreign import io.primitives_read so that prototype for
     mercury_get_byte() is visible to the C code in this module.

     Document what each expected output is for.

tests/debugger/tailrec1.exp:
     Conform to the above change. XXX The term size profiling grades
     are suffering from some bitrot, the .exp2 file can be fixed
     when they are.

Julien.

diff --git a/tests/debugger/tailrec1.exp b/tests/debugger/tailrec1.exp
index 24987da6e..cf7a0097a 100644
--- a/tests/debugger/tailrec1.exp
+++ b/tests/debugger/tailrec1.exp
@@ -1,4 +1,4 @@
-      E1:     C1 CALL pred tailrec1.main/2-0 (det) tailrec1.m:19
+      E1:     C1 CALL pred tailrec1.main/2-0 (det) tailrec1.m:23
 mdb> echo on
 Command echo enabled.
 mdb> register --quiet
diff --git a/tests/debugger/tailrec1.m b/tests/debugger/tailrec1.m
index c7ae50023..5f3268d3c 100644
--- a/tests/debugger/tailrec1.m
+++ b/tests/debugger/tailrec1.m
@@ -1,9 +1,11 @@
 %---------------------------------------------------------------------------%
 % vim: ts=4 sw=4 et ft=mercury
 %---------------------------------------------------------------------------%
+% The .exp file is for when term size profiling is not enabled.
+% The .exp2 is for when term size profiling is enabled.
+%---------------------------------------------------------------------------%

 :- module tailrec1.
-
 :- interface.

 :- import_module io.
@@ -16,6 +18,8 @@
 :- import_module list.
 :- import_module string.

+:- pragma foreign_import_module("C", io.primitives_read).
+
 main(!IO) :-
     io.open_input("tailrec1.data", Result, !IO),
     (


More information about the reviews mailing list