[m-rev.] for post-commit review: fixes for inst definition error messages
Julien Fischer
jfischer at opturion.com
Thu Mar 16 11:38:35 AEDT 2017
Fixes for inst definition error messages.
compiler/parse_inst_mode_defn.m:
Expand the acronyms LHS and RHS in error messages.
Fix the error message concerning repeated inst parameters on the
left hand size of an inst definition; the existing wording doesn't
make sense.
tests/invalid/Mmakefile:
tests/invalid/bad_inst_defn.{m,err_exp}:
Add a test case covering the above error messages.
Julien.
diff --git a/compiler/parse_inst_mode_defn.m b/compiler/parse_inst_mode_defn.m
index 93e9731..f918be1 100644
--- a/compiler/parse_inst_mode_defn.m
+++ b/compiler/parse_inst_mode_defn.m
@@ -313,9 +313,9 @@ check_inst_mode_defn_args(DefnKind, VarSet, HeadTermContext,
DupVarNames =
list.map(mercury_var_to_name_only(VarSet), DupArgVars),
RepeatPieces = [words("Error: inst"), words(ParamWord)] ++
- list_to_pieces(DupVarNames) ++
- [words(IsAreWord), words("in LHS of"), words(DefnKind),
- suffix("."), nl],
+ list_to_quoted_pieces(DupVarNames) ++
+ [words(IsAreWord), words("repeated on left hand side of"),
+ words(DefnKind), suffix("."), nl],
RepeatSpec = error_spec(severity_error,
phase_term_to_parse_tree,
[simple_msg(HeadTermContext, [always(RepeatPieces)])]),
@@ -341,8 +341,9 @@ check_inst_mode_defn_args(DefnKind, VarSet, HeadTermContext,
FreePieces = [words("Error: free inst"),
words(choose_number(FreeVars,
"parameter", "parameters"))] ++
- list_to_pieces(FreeVarNames) ++
- [words("in RHS of"), words(DefnKind), suffix("."), nl],
+ list_to_quoted_pieces(FreeVarNames) ++
+ [words("on right hand side of"),
+ words(DefnKind), suffix("."), nl],
FreeSpec = error_spec(severity_error,
phase_term_to_parse_tree,
[simple_msg(get_term_context(BodyTerm),
diff --git a/tests/invalid/Mmakefile b/tests/invalid/Mmakefile
index 88bd70d..9f4acb8 100644
--- a/tests/invalid/Mmakefile
+++ b/tests/invalid/Mmakefile
@@ -60,6 +60,7 @@ SINGLEMODULE= \
bad_foreign_proc \
bad_foreign_type \
bad_initialise_decl \
+ bad_inst_defn \
bad_inst_for_type \
bad_instance \
bad_instance2 \
diff --git a/tests/invalid/bad_inst_defn.err_exp b/tests/invalid/bad_inst_defn.err_exp
index e69de29..ed9a261 100644
--- a/tests/invalid/bad_inst_defn.err_exp
+++ b/tests/invalid/bad_inst_defn.err_exp
@@ -0,0 +1,8 @@
+bad_inst_defn.m:013: Error: free inst parameter `B' on right hand side of inst
+bad_inst_defn.m:013: definition.
+bad_inst_defn.m:015: Error: free inst parameters `B' and `C' on right hand side
+bad_inst_defn.m:015: of inst definition.
+bad_inst_defn.m:017: Error: inst parameter `A' is repeated on left hand side of
+bad_inst_defn.m:017: inst definition.
+bad_inst_defn.m:019: Error: inst parameters `A' and `B' are repeated on left
+bad_inst_defn.m:019: hand side of inst definition.
diff --git a/tests/invalid/bad_inst_defn.m b/tests/invalid/bad_inst_defn.m
index e69de29..9f397ff 100644
--- a/tests/invalid/bad_inst_defn.m
+++ b/tests/invalid/bad_inst_defn.m
@@ -0,0 +1,19 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+%
+% Test for error messages produced by syntax errors in inst definitions.
+%
+
+:- module bad_inst_defn.
+:- interface.
+
+:- type mylist(T) ---> [] ; [T | mylist(T)].
+
+:- inst test1(A) ---> [] ; [B | mylistskel(A)].
+
+:- inst test2(A) ---> [] ; [B | mylistskel(C)].
+
+:- inst test3(A, A) ---> [] ; [A | mylistskel(A)].
+
+:- inst test4(A, A, B, B) ---> [] ; [A | mylistskel(B)].
More information about the reviews
mailing list