[m-rev.] diff: fix an incorrect pragma name in some error messages

Julien Fischer jfischer at opturion.com
Mon May 16 15:49:48 AEST 2016


Fix an incorrect pragma name in some error messages.

compiler/parse_pragma.m:
      Fix a problem where the code for parsing 'foreign_enum' pragmas
      is incorrectly referring to them as 'foreign_export_enum' pragmas
      in some error messages.

tests/invalid/Mmakefile:
tests/invalid/bad_foreign_enum.{m,err_ex}:
      Add a regression test for the above problem.

Julien.

diff --git a/compiler/parse_pragma.m b/compiler/parse_pragma.m
index 089d9a7..8b5bd60 100644
--- a/compiler/parse_pragma.m
+++ b/compiler/parse_pragma.m
@@ -767,7 +767,7 @@ parse_pragma_foreign_enum(VarSet, ErrorTerm, PragmaTerms, Context, SeqNum,
              )
          else
              Pieces = [words("Error: invalid foreign language in"),
-                pragma_decl("foreign_export_enum"), words("declaration."),
+                pragma_decl("foreign_enum"), words("declaration."),
                  nl],
              % XXX We should use the context of LangTerm.
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
@@ -776,7 +776,7 @@ parse_pragma_foreign_enum(VarSet, ErrorTerm, PragmaTerms, Context, SeqNum,
          )
      else
          Pieces = [words("Error: wrong number of arguments in"),
-            pragma_decl("foreign_export_enum"), words("declaration."), nl],
+            pragma_decl("foreign_enum"), words("declaration."), nl],
          Spec = error_spec(severity_error, phase_term_to_parse_tree,
              [simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
          MaybeIOM = error1([Spec])
diff --git a/tests/invalid/Mmakefile b/tests/invalid/Mmakefile
index ab5fe98..1bfc046 100644
--- a/tests/invalid/Mmakefile
+++ b/tests/invalid/Mmakefile
@@ -49,6 +49,7 @@ SINGLEMODULE= \
  	bad_consider_used \
  	bad_detism \
  	bad_end_module \
+	bad_foreign_enum \
  	bad_finalise_decl \
  	bad_initialise_decl \
  	bad_inst_for_type \
diff --git a/tests/invalid/bad_foreign_enum.err_exp b/tests/invalid/bad_foreign_enum.err_exp
new file mode 100644
index 0000000..9676258
--- /dev/null
+++ b/tests/invalid/bad_foreign_enum.err_exp
@@ -0,0 +1,4 @@
+bad_foreign_enum.m:024: Error: wrong number of arguments in
+bad_foreign_enum.m:024:   `:- pragma foreign_enum' declaration.
+bad_foreign_enum.m:028: Error: invalid foreign language in
+bad_foreign_enum.m:028:   `:- pragma foreign_enum' declaration.
diff --git a/tests/invalid/bad_foreign_enum.m b/tests/invalid/bad_foreign_enum.m
new file mode 100644
index 0000000..58e857a
--- /dev/null
+++ b/tests/invalid/bad_foreign_enum.m
@@ -0,0 +1,28 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+%
+% Regression test: rotd-2016-05-16 and before incorrectly reported the errors
+% in the foreign_enum pragmas as occurring in foreign_export_enum pragmas.
+
+:- module bad_foreign_enum.
+:- interface.
+
+:- type fruit
+    --->   orange
+    ;      lemon
+    ;      apple.
+
+:- type more_fruit
+    --->   pear
+    ;      grapefruit.
+
+:- implementation.
+
+    % Wrong number of arguments.
+    %
+:- pragma foreign_enum("C", fruit/0, [], []).
+
+    % Invalid foreign language.
+    %
+:- pragma foreign_enum("UnsupportedLanguage", more_fruit/0, []).


More information about the reviews mailing list