next up previous contents
Next: Preregularity and equational attributes Up: Traps and known problems Previous: Bare variable lefthand sides   Contents


Operator overloading and associativity

The situation where two ad-hoc overloaded operators have the same kinds in their arities but different ones in their coarities causes a warning to be emitted, as already mentioned in Section 3.6. For example, loading the file overloading-assoc-warning.maude containing the module

  fmod OVER-ASSOC-EX1 is
    sorts Foo Bar .
    op f : Foo -> Foo .
    op f : Foo -> Bar .
  endfm

causes the following warning:

  Warning: "overloading-assoc-warning.maude", line 8 (fmod 
    OVER-ASSOC-EX1): declaration for f has the same domain kinds as 
    the declaration on "overloading-assoc-warning.maude", line 7 
    (fmod OVER-ASSOC-EX1) but a different range kind.

A similar warning is obtained in the case where the arities differ but might look the same because of associativity, like in the following example (loaded as before):

  fmod OVER-ASSOC-EX2 is
    sort Foo .
    op f : Foo Foo -> Foo [assoc] .
    op f : Foo Foo Foo -> Foo .
  endfm

  Warning: "overloading-assoc-warning.maude", line 22 
    (fmod OVER-ASSOC-EX2): declaration for f clashes with 
    declaration on "overloading-assoc-warning.maude", line 21 (fmod 
    OVER-ASSOC-EX2) because of associativity.



The Maude Team