mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
Expand diagostic for bad state var refs.
compiler/typecheck_error_undef.m:
As above.
tests/invalid/field_syntax_error.err_exp:
Expect the new output.
This commit is contained in:
@@ -636,14 +636,19 @@ syntax_functor_components(FunctorName, Arity, Components) :-
|
||||
(
|
||||
Arity = 1,
|
||||
FunctorName = "!",
|
||||
Pieces1 = [words("error:")] ++
|
||||
Pieces = [words("error:")] ++
|
||||
color_as_incorrect([words("invalid use of the"), quote("!"),
|
||||
words("state variable operator.")]) ++
|
||||
[nl] ++
|
||||
color_as_hint([words("You probably meant to type"),
|
||||
quote("!."), words("or"), quote("!:"),
|
||||
words("instead of just"), quote("!"), suffix(".")]) ++
|
||||
[nl,
|
||||
words("If you are trying to do a field update, then")] ++
|
||||
color_as_hint([words("you probably typed"), quote("="),
|
||||
words("where you meant to type"), quote(":="), suffix(".")]) ++
|
||||
[nl],
|
||||
Pieces2 = color_as_hint([words("You probably meant to use"),
|
||||
quote("!."), words("or"), quote("!:"), suffix(".")]) ++
|
||||
[nl],
|
||||
Components = [always(Pieces1), verbose_only(verbose_always, Pieces2)]
|
||||
Components = [always(Pieces)]
|
||||
;
|
||||
Arity = 2,
|
||||
(
|
||||
|
||||
@@ -37,6 +37,10 @@ field_syntax_error.m:034: In clause for function `baz5'/1:
|
||||
field_syntax_error.m:034: in argument 1 of functor `f2/1':
|
||||
field_syntax_error.m:034: error: [38;5;203minvalid use of the `!' state variable[39;49m
|
||||
field_syntax_error.m:034: [38;5;203moperator.[39;49m
|
||||
field_syntax_error.m:034: [38;5;226mYou probably meant to type `!.' or `!:' instead of[39;49m
|
||||
field_syntax_error.m:034: [38;5;226mjust `!'.[39;49m
|
||||
field_syntax_error.m:034: If you are trying to do a field update, then [38;5;226myou[39;49m
|
||||
field_syntax_error.m:034: [38;5;226mprobably typed `=' where you meant to type `:='.[39;49m
|
||||
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: followed by [38;5;40m`:=',[39;49m not [38;5;203m`='.[39;49m
|
||||
|
||||
Reference in New Issue
Block a user