[m-rev.] diff: fix a failing test case

Julien Fischer jfischer at opturion.com
Sun Oct 5 16:04:25 AEDT 2025


Fix a failing test case.

The test case hard_coded/intermod_foreign_type is failing in the C# grades due
to a missing foreign_type pragma. When originally added this test case had a
foreign_type pragma for IL, but at some point that was deleted (presumably at
the same time the IL backend was removed). This meant that for C# grades, the
coord/0 type would default to its Mercury definition, which conflicts with
the handwritten definition used by the C# foreign_procs.
The fix is to add a C# foreign_type pragma.

tests/hard_coded/intermod_foreign_type.m:
tests/hard_coded/intermod_foreign_type_helper_1.m:
    Add a missing c# foreign_type pragma.

    Delete unused imports.

Julien.

diff --git a/tests/hard_coded/intermod_foreign_type.m
b/tests/hard_coded/intermod_foreign_type.m
index d80b13949..c65de2590 100644
--- a/tests/hard_coded/intermod_foreign_type.m
+++ b/tests/hard_coded/intermod_foreign_type.m
@@ -3,17 +3,18 @@
 %---------------------------------------------------------------------------%

 :- module intermod_foreign_type.
-
 :- interface.

 :- import_module io.

 :- pred main(io::di, io::uo) is det.

+%---------------------------------------------------------------------------%
+%---------------------------------------------------------------------------%
+
 :- implementation.

 :- import_module intermod_foreign_type_helper_1.
-:- import_module std_util.

 main(!IO) :-
     C = new(4, 5),
diff --git a/tests/hard_coded/intermod_foreign_type_helper_1.m
b/tests/hard_coded/intermod_foreign_type_helper_1.m
index 4e59b966c..665957430 100644
--- a/tests/hard_coded/intermod_foreign_type_helper_1.m
+++ b/tests/hard_coded/intermod_foreign_type_helper_1.m
@@ -17,8 +17,6 @@

 :- implementation.

-:- import_module std_util.
-
 :- pragma foreign_decl("C#", "
 public class coord {
     public int x;
@@ -51,7 +49,11 @@ public class coord {

 %---------------------------------------------------------------------------%

-% Mercury implementation
+% C# implementation.
+
+:- pragma foreign_type("C#", coord, "coord").
+
+% Mercury implementation.

 :- type coord
     --->    coord(x :: int, y :: int).


More information about the reviews mailing list