[Openmcl-devel] No warning when defun parameters to not match ftype decleration
burton.samograd at gmail.com
Sat Jul 21 22:38:18 CDT 2012
In the following example, I'm curious about it's behaviour:
cat <<EOF > no-warning.lisp
(declaim (ftype (function (list) t) x)))
(defun x () (+ 1 1))
ccl --eval "(progn (compile-file \"no-warning.lisp\" :output-file \"no-warning.lo\") (quit))"
;Compiler warnings for "no-warning.lisp" :
; In an anonymous lambda form at position 99: In the call to X with arguments (),
; 0 arguments were provided, but at least 1 is required
; by the FTYPE declaration of X
The ftype decleration does cause a warning when trying to call the
function with the wrong number of parameters, but it does not complain
when defining the function with the wrong parameters. SBCL does
notice the problem and complains:
$ sbcl --eval "(progn (compile-file \"no-warning.lisp\" :output-file \"no-warning.lo\") (quit))"
This is SBCL 188.8.131.52-a5f57fb, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
; compiling file "/home/x/xlang/no-warning.lisp" (written 21 JUL 2012 02:37:25 PM):
; compiling (DEFUN X ...)
; file: /home/x/xlang/no-warning.lisp
; in: DEFUN X
; (DEFUN X () (+ 1 1))
; --> PROGN EVAL-WHEN
; (SB-IMPL::%DEFUN 'X
; (SB-INT:NAMED-LAMBDA X
; (BLOCK X (+ 1 1)))
; NIL 'NIL (SB-C:SOURCE-LOCATION))
; caught STYLE-WARNING:
; The definition has zero args, but the proclamation has one.
; compiling (X);
; compilation unit finished
; caught 1 STYLE-WARNING condition
; /home/x/xlang/no-warning.lo written
; compilation finished in 0:00:00.003
I was hoping to be able to send in a patch to emit the warning,
but ran into a brick wall. Trying to get the ftype information by
calling (lexenv.fdecls env) always returnes nil when called in
the defun macro using the passed environment. This was my first
stab a solution so this might not have been a correct method to
implement such a warning, but thought I would pass this
information along to see if I could get some help on how to do it
More information about the Openmcl-devel