Opened 14 years ago
Last modified 14 years ago
#1247 closed defect (fixed)
Improve error message for mixing equation/algorithm syntax (from MathCore)
Reported by: | Peter Aronsson | Owned by: | Peter Aronsson |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Version: | ||
Keywords: | Cc: | Peter Aronsson, Martin Sjölund |
Description
The model test below returns the message:
{{{--- [12] 11:19:09 Syntax error(s) in model test ---
test(8) : error: expecting an identifier, found 'if'}}}
{{{model test
Real y;
equation
if true then
y:=1;
else
y:=2;
end if;
end test;}}}
The error is that ':=' is used instead of '='. It is very easy to mix these things up for a novice user so a better error message is needed.
Change History (5)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
The new parser outputs:
[a.mo:5:6-5:7:writable] Error: No viable alternative near token: :=
Is this good enough or should we have a customized error message?
comment:3 by , 14 years ago
This is the most common syntactic error that new users do, so I think that a customized error message could be good for just this case.
comment:4 by , 14 years ago
This now yields
[a.mo:5:6-5:7:writable] Error: Parse error: Equations can not contain assignments (':='), use equality ('=') instead
(in my local copy)
(Previously, only the reverse, equation syntax in algorithms, was handled as a special case.)
(MathCore TRAC http://intranet/trac/mathmodelica/ticket/1693)