ClojureScript

Duplicate protocols in defrecord are silently ignored

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Clojurescript 1913

Description

It is currently not an error to define a type with two implementations of the same protocol; which implementation is actually used appears to be arbitrary. This shouldn't be allowed, as it leads to mysterious misbehavior like the following:

(defrecord MyCountableThing [count]
  ICounted
  (-count [_] count))

Calling count on any instance of MyCountableThing will of course return 1, which is the the answer given by the default implementation of ICounted in the defrecord macro. I'm not arguing here that the above code should necessarily work; indeed the semantics of defrecord make it reasonable for it not to. But it should be an error rather than doing nothing.

Activity

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: