overturetool / overture

The Overture Tool
http://overturetool.org
GNU General Public License v3.0
48 stars 25 forks source link

Type checker: Issue with type checking of operation with union type arguments #493

Closed peterwvj closed 8 years ago

peterwvj commented 8 years ago

The spec below does not type check and we believe it should. It is as if the type checker does not recognize op: A * char and op: B * int as valid solutions for the call when op is declared inside B.

The problem is the same for VDMJ.

class A

operations

public run : () ==> ()
run () ==
let x : A | B = new B()
in
  x.op(x,-1); -- <- ERROR: Member op((A | B), int) is not in scope. 

end A

class B

operations

public op : A * char ==> ()
op (-,-) == skip;

public op : B * int ==> ()
op (-,-) == skip;

end B

If the two operations named op are moved to class A then it type checks without errors.

ldcouto commented 8 years ago

Certainly possible. Let's consider this as fixed. If we end deciding differently on the semantics, we can always come back.

tomooda commented 8 years ago

I'm happy with the "public" hack as far as the pseudo class behaves as expected with regard to type compatibility (e.g. is_ expression, assignment and access control of members). I agree to close this issue.

peterwvj commented 8 years ago

Great. I'm also happy with this solution. This issue will close automatically, when Nick's fix gets merged into development.