Opened 10 years ago

Last modified 7 years ago

#3235 closed defect

Fix test cases with error messages that include line numbers from the compiler — at Version 5

Reported by: Per Östlund Owned by: somebody
Priority: high Milestone: Future
Component: *unknown* Version: trunk
Keywords: Cc: Lennart Ochel, Willi Braun, Volker Waurich

Description (last modified by Per Östlund)

I have disabled some test cases that have error messages in them which include line numbers from the compiler. This means that the test cases needs to be updated every time the corresponding source files are changed in the compiler, which is not acceptable. Internal errors should really only be used for things which shouldn't fail, and not used as failtraces.

So either the compiler needs to be fixed so it doesn't print out internal errors for these models, or the models needs to be fixed. The models are:

simulation/modelica/indexreduction/ImplicitStateCoupling.mos
simulation/libraries/3rdParty/MathematicalAspects/01_AlgebraicLoopBoolean.mos
openmodelica/typed-API/SolveLinearSystem.mos
simulation/modelica/algorithms_functions/algorithms.mos

Change History (5)

comment:1 by Per Östlund, 10 years ago

Also, the following pattern is often used in the front end:

function foo
  ...
protected
  Integer err_count = Error.getNumErrorMessages();
algorithm
  try
    // Something which can fail.
  else
    if err_count == Error.getNumErrorMessages() then
      Error.addInternalError(...);
    end if;
  end try;
end foo;

I.e. only print an internal error if the called code fails without printing an error of its own. This is probably a pattern which should be used more in the backend, considering that getNumErrorMessages is used five times in the whole backend, while internal errors are used in ~250 places.

comment:2 by Volker Waurich, 10 years ago

Thanks for adressing this issue. I appreciate these recommendation to get a more consistent coding style. Could you add this to the style guide?

comment:3 by Martin Sjölund, 10 years ago

I will just note that a lot of the addInternalError calls were added by me; they were often replacing print statements (which is worse than just failtrace).

in reply to:  2 comment:4 by Per Östlund, 10 years ago

Replying to vwaurich:

Could you add this to the style guide?

Done.

comment:5 by Per Östlund, 10 years ago

Description: modified (diff)

algorithms.mos added to the list.

Note: See TracTickets for help on using tickets.