Opened 12 years ago

Closed 12 years ago

#1844 closed defect (fixed)

Incorrect Type Unboxing (?) when calling funargs in if expressions

Reported by: adabe588@… Owned by: Martin Sjölund
Priority: high Milestone: 1.9.0
Component: Frontend Version: trunk
Keywords: Cc:

Description

The call to predicate in this code throws Error: Type error in conditional ( predicate(#(i))). Expected Boolean, got #Boolean (in component: <NO COMPONENT>).. Using anything other than an if expression seems to work properly (inside if statement, plain call), and calling constTrue directly in the if expression instead of the funarg also works.

package Test

function f
  input Predicate predicate;
  input Integer i;
  output Integer r;
protected
  partial function Predicate
    input Integer value;
    output Boolean result;
  end Predicate;
algorithm
  r := if predicate(i) then 1 else 2;
end f;

function constTrue
  input Integer x;
  output Boolean t;
algorithm
  t := true;
end constTrue;

function test
algorithm
  f(constTrue, 0);
end test;

end Test;

Change History (2)

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

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

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

Component: BackendFrontend
Resolution: fixed
Status: acceptedclosed

Fixed in r13076.

Note: See TracTickets for help on using tickets.