Opened 10 years ago

Closed 10 years ago

#3063 closed defect (fixed)

MetaModelica string match issues

Reported by: adrpo Owned by: sjoelund.se
Priority: high Milestone: 1.9.2
Component: MetaModelica Version: trunk
Keywords: Cc:

Description (last modified by adrpo)

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 Changed 10 years ago by adrpo

  • Description modified (diff)

comment:2 Changed 10 years ago by sjoelund.se

  • Status changed from new to accepted

comment:3 Changed 10 years ago by sjoelund.se

  • Milestone changed from Future to 1.9.2
  • Resolution set to fixed
  • Status changed from accepted to closed

Fixed in r24003

Note: See TracTickets for help on using tickets.