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:
Zoltan Somogyi
2025-12-27 01:05:16 +11:00
parent 692ea456b8
commit 7238c14618
2 changed files with 14 additions and 5 deletions

View File

@@ -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,
(

View File

@@ -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: invalid use of the `!' state variable
field_syntax_error.m:034: operator.
field_syntax_error.m:034: You probably meant to type `!.' or `!:' instead of
field_syntax_error.m:034: just `!'.
field_syntax_error.m:034: If you are trying to do a field update, then you
field_syntax_error.m:034: probably typed `=' where you meant to type `:='.
field_syntax_error.m:034: Warning: if the expression `!Foo ^ f2' 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 `:=', not `='.