ccl
ccl copied to clipboard
Non-conformity: warning on duplicate DEFMETHOD in same file
When compiling (via SLY's C-c C-k sly-compile-and-load-file or ASDF's load-system, both of which I believe invoke compile-file), a file containing:
(defgeneric foo (bar))
(defmethod foo ((bar number))
(1+ bar))
(defmethod foo ((bar number))
(1+ bar))
signals a :duplicate-definition warning:
warning: Duplicate definitions of (:METHOD FOO (NUMBER)), in this file
ASDF treats this as a compilation failure and aborts the compile-op.
I've looked, and can find no justification for this in the spec. Section 3.2.2.3: Compilation Semantics, Semantic Constraints says that conforming programs may not multiply define functions within a file, but says nothing about multiple definition of methods, generic functions, or anything else. SBCL, which I generally trust when it comes to ANSI compliance, signals a warning on duplicated function definition, but a style-warning on duplicated method definition. As per 3.2.5: Exceptional Situations in the Compiler, I believe a style-warning is the most extreme condition a compiler can signal in this position while conforming to the spec.
FWIW, CMUCL doesn't say anything when I ask it to compile the above segment.