Opened 12 years ago

Closed 12 years ago

#1786 closed defect (fixed)

Empty list pattern incorrectly used causes an endless loop

Reported by: adabe588@… Owned by: sjoelund.se
Priority: normal Milestone: 1.9.0
Component: Frontend Version:
Keywords: Cc:

Description (last modified by sjoelund.se)

This causes infinite loop of error messages when trying to match a function against {}.
Should halt at the first type error.
If debug flags aren't present it loops silently.

package PatternMatchInvalidType

partial function Nothing
end Nothing;

function nothing
algorithm
end nothing;

public function test1
  input Nothing n;
algorithm
  _ := match(n)
    case ({}) then ();
    else fail();
  end match;
end test1;

public function test
algorithm
  test1(nothing);
end test;

end PatternMatchInvalidType;
setCommandLineOptions({"+d=rml,noevalfunc,failtrace","+g=MetaModelica","+showAnnotations","+showErrorMessages"});

loadFile("PatternMatchInvalidType.mo");
getErrorString();
// Result:
// true
// ""
// endResult

PatternMatchInvalidType.test();
getErrorString();
{true,true,true,true}
true
""
- Static.elabCrefSubs failed on: <Prefix.NOPRE()>.nothing env: PatternMatchInvalidType.test
{"[PatternMatchInvalidType.mo:14:10-14:15:writable] Error: Type mismatch in pattern {}
actual type:
  list<#T_UNKNOWN#>
expected type:
  .PatternMatchInvalidType.Nothing<function>() => #NORETCALL#", "TRANSLATION", "Error", "5022"}
{"[PatternMatchInvalidType.mo:14:10-14:15:writable] Error: Type mismatch in pattern {}
actual type:
  list<#T_UNKNOWN#>
expected type:
  .PatternMatchInvalidType.Nothing<function>() => #NORETCALL#", "TRANSLATION", "Error", "5022"}
{"[PatternMatchInvalidType.mo:14:10-14:15:writable] Error: Type mismatch in pattern {}
actual type:
  list<#T_UNKNOWN#>

... and so on

Change History (2)

comment:1 Changed 12 years ago by sjoelund.se

  • Owner changed from somebody to sjoelund.se
  • Status changed from new to assigned

comment:2 Changed 12 years ago by sjoelund.se

  • Description modified (diff)
  • Resolution set to fixed
  • Status changed from assigned to closed
  • Summary changed from Incorrectly pattern matching on a function pointer causes an endless loop of error messages to Empty list pattern incorrectly used causes an endless loop

Fixed in r12688.

Note: See TracTickets for help on using tickets.