Opened 10 years ago

Closed 10 years ago

#3063 closed defect (fixed)

MetaModelica string match issues

Reported by: Adrian Pop Owned by: Martin Sjölund
Priority: high Milestone: 1.9.2
Component: MetaModelica Version: trunk
Keywords: Cc:

Description (last modified by Adrian Pop)

The match below will fail when ident is "IncludeDirectory", it will not return "bad".

ident := "IncludeDirectory";
x := match ident
  case "choices"              then "";
  case "Documentation"        then "";
  case "Dialog"               then "";
  case "Diagram"              then "";
  case "Icon"                 then "";
  case "Line"                 then "";
  case "Placement"            then "";
  case "preferredView"        then "";
  case "conversion"           then "";
  case "defaultComponentName" then "";
  case "revisionId"           then "";
  case "uses"                 then "";
  else then "bad";
end match;

This happens because the match is transformed to switch on the hash of the string and after the case is selected a comparison is made and if the comparison fails it jumps directly to the end of the switch. It should jump to the default case of the switch if the string comparison fails.

Change History (3)

comment:1 by Adrian Pop, 10 years ago

Description: modified (diff)

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

Status: newaccepted

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

Milestone: Future1.9.2
Resolution: fixed
Status: acceptedclosed

Fixed in r24003

Note: See TracTickets for help on using tickets.