Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3633 closed defect (fixed)

Returning from a non-returning match generates bad code

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: normal Milestone: 1.9.4
Component: MetaModelica Version:
Keywords: Cc:

Description

Running this script:

setCommandLineOptions("-g=MetaModelica");

loadString("
  function test
    input Integer n;
  algorithm
    _ := match n
      local
        Integer x;

      case 1
        algorithm
          x := n;
        then
          x;

    end match;
  end test;
");
test(1);
getErrorString();

causes the code generation to generate the line:

 = (modelica_integer)_n;

The expected behaviour is that the compiler gives an error when trying to return x from the case, since the match is declared to not return anything.

Change History (4)

comment:1 by Per Östlund, 9 years ago

Resolution: fixed
Status: newclosed

Fixed in 8c9025a. I was wrong in saying an error should be generated, the code should in fact work (but won't do anything).

comment:2 by Dietmar Winkler, 9 years ago

Milestone: Future1.9.4

Sorting these closed tickets away from "Future". Since they were closed after the last 1.9.3 release, it's very likely that they should have been part of the 1.9.4 release.

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

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:4 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.