mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
Improve two rarely-seen diagnostics.
compiler/parse_type_defn.m:
As above.
tests/invalid/field_syntax_error.{m,err_exp}:
tests/invalid/types.{m,err_exp}:
Add an instance of each bug the diagnostics are for,
and test for the updated diagnostic text.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
% vim: ft=mercury ts=4 sw=4 et
|
% vim: ft=mercury ts=4 sw=4 et
|
||||||
%-----------------------------------------------------------------------------e
|
%-----------------------------------------------------------------------------e
|
||||||
% Copyright (C) 2008-2011 The University of Melbourne.
|
% Copyright (C) 2008-2011 The University of Melbourne.
|
||||||
% Copyright (C) 2016-2025 The Mercury team.
|
% Copyright (C) 2016-2026 The Mercury team.
|
||||||
% This file may only be copied under the terms of the GNU General
|
% This file may only be copied under the terms of the GNU General
|
||||||
% Public License - see the file COPYING in the Mercury distribution.
|
% Public License - see the file COPYING in the Mercury distribution.
|
||||||
%---------------------------------------------------------------------------%
|
%---------------------------------------------------------------------------%
|
||||||
@@ -525,9 +525,12 @@ convert_constructor_arg_list(ModuleName, VarSet, [Term | Terms])
|
|||||||
MaybeSymNameAndArgs = ok2(SymName, SymNameArgs),
|
MaybeSymNameAndArgs = ok2(SymName, SymNameArgs),
|
||||||
(
|
(
|
||||||
SymNameArgs = [_ | _],
|
SymNameArgs = [_ | _],
|
||||||
% XXX Should we add "... at function symbol ..."?
|
NameTermStr = describe_error_term(VarSet, NameTerm),
|
||||||
Pieces = [words("Error: syntax error in constructor name."),
|
Pieces = [words("Error: expected a")] ++
|
||||||
nl],
|
color_as_correct([words("simple identifier")]) ++
|
||||||
|
[words("as the field name, got")] ++
|
||||||
|
color_as_incorrect([words(NameTermStr), suffix(".")]) ++
|
||||||
|
[nl],
|
||||||
Spec = spec($pred, severity_error, phase_t2pt,
|
Spec = spec($pred, severity_error, phase_t2pt,
|
||||||
get_term_context(Term), Pieces),
|
get_term_context(Term), Pieces),
|
||||||
MaybeConstructorArgs = error1([Spec])
|
MaybeConstructorArgs = error1([Spec])
|
||||||
@@ -906,8 +909,8 @@ parse_eqv_type_defn(ModuleName, VarSet, HeadTerm, BodyTerm, Context, SeqNum,
|
|||||||
cord.from_list([words("On the left hand side of type definition:")]),
|
cord.from_list([words("On the left hand side of type definition:")]),
|
||||||
parse_type_defn_head(HeadContextPieces, ModuleName, VarSet, HeadTerm,
|
parse_type_defn_head(HeadContextPieces, ModuleName, VarSet, HeadTerm,
|
||||||
MaybeNameAndParams),
|
MaybeNameAndParams),
|
||||||
% XXX Should pass more correct BodyContextPieces.
|
BodyContextPieces = cord.from_list(
|
||||||
BodyContextPieces = cord.init,
|
[words("On the right hand side of equivalence type definition:")]),
|
||||||
parse_type(allow_ho_inst_info, VarSet, BodyContextPieces, BodyTerm,
|
parse_type(allow_ho_inst_info, VarSet, BodyContextPieces, BodyTerm,
|
||||||
MaybeType),
|
MaybeType),
|
||||||
( if
|
( if
|
||||||
|
|||||||
@@ -45,4 +45,6 @@ field_syntax_error.m:034: [38;5;226mprobably typed `=' where you meant to typ
|
|||||||
field_syntax_error.m:034: Warning: if the expression [38;5;87m`!Foo ^ f2'[39;49m is intended to
|
field_syntax_error.m:034: Warning: if the expression [38;5;87m`!Foo ^ f2'[39;49m is intended to
|
||||||
field_syntax_error.m:034: be part of a field update, then it should be
|
field_syntax_error.m:034: be part of a field update, then it should be
|
||||||
field_syntax_error.m:034: followed by [38;5;40m`:=',[39;49m not [38;5;203m`='.[39;49m
|
field_syntax_error.m:034: followed by [38;5;40m`:=',[39;49m not [38;5;203m`='.[39;49m
|
||||||
|
field_syntax_error.m:037: Error: expected a [38;5;40msimple identifier[39;49m as the field
|
||||||
|
field_syntax_error.m:037: name, got [38;5;203mf(N).[39;49m
|
||||||
For more information, recompile with `-E'.
|
For more information, recompile with `-E'.
|
||||||
|
|||||||
@@ -32,3 +32,6 @@ baz4(Foo) = Foo^44:=45.
|
|||||||
baz5(!.Foo) = !:Foo :-
|
baz5(!.Foo) = !:Foo :-
|
||||||
!Foo ^ f1 := 42,
|
!Foo ^ f1 := 42,
|
||||||
!Foo ^ f2 = 43.
|
!Foo ^ f2 = 43.
|
||||||
|
|
||||||
|
:- type bar
|
||||||
|
---> bar(f(N) :: int).
|
||||||
|
|||||||
@@ -44,3 +44,5 @@ types.m:063: declaration for module `string'.
|
|||||||
types.m:072: In clause for predicate `repeated_arity'/3:
|
types.m:072: In clause for predicate `repeated_arity'/3:
|
||||||
types.m:072: error: [38;5;203mwrong number of arguments[39;49m ([38;5;203m2[39;49m; should be [38;5;40m3[39;49m)
|
types.m:072: error: [38;5;203mwrong number of arguments[39;49m ([38;5;203m2[39;49m; should be [38;5;40m3[39;49m)
|
||||||
types.m:072: in call to predicate [38;5;87m`append'.[39;49m
|
types.m:072: in call to predicate [38;5;87m`append'.[39;49m
|
||||||
|
types.m:080: On the right hand side of equivalence type definition: error: [38;5;87m`5'[39;49m
|
||||||
|
types.m:080: is [38;5;203mnot a type.[39;49m
|
||||||
|
|||||||
@@ -76,3 +76,5 @@ repeated_arity(A, B, C) :-
|
|||||||
|
|
||||||
append(A, B, C) :-
|
append(A, B, C) :-
|
||||||
C = A + B.
|
C = A + B.
|
||||||
|
|
||||||
|
:- type nonsense == 5.
|
||||||
|
|||||||
Reference in New Issue
Block a user