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: Martin Sjölund
Priority: normal Milestone: 1.9.0
Component: Frontend Version:
Keywords: Cc:

Description (last modified by Martin Sjölund)

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 by Martin Sjölund, 12 years ago

Owner: changed from somebody to Martin Sjölund
Status: newassigned

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

Description: modified (diff)
Resolution: fixed
Status: assignedclosed
Summary: Incorrectly pattern matching on a function pointer causes an endless loop of error messagesEmpty list pattern incorrectly used causes an endless loop

Fixed in r12688.

Note: See TracTickets for help on using tickets.