From: Nikodemus S. <nik...@ra...> - 2009-05-06 11:19:59
|
2009/5/6 Rupert Swarbrick <rsw...@go...>: > (defun testme (txt) > (cl-ppcre:register-groups-bind > (a) ("([0-9]+)" txt) > (parse-integer a))) Expanding the REGISTER-GROUPS-BIND inline gives (defun testme (txt) (let ((target-string951 txt)) (multiple-value-bind (match-start952 match-end953 reg-starts954 reg-ends955) (cl-ppcre:scan "([0-9]+)" target-string951 :start (or nil 0) :end (or nil (length target-string951))) (declare (ignore match-end953)) (when match-start952 (let* ((substr-fn957 (if nil #'cl-ppcre::nsubseq #'subseq)) (a (let ((start-index956 (aref reg-starts954 0))) (IF START-INDEX956 (FUNCALL #'IDENTITY (FUNCALL SUBSTR-FN957 TARGET-STRING951 START-INDEX956 (AREF REG-ENDS955 0))) NIL)))) (parse-integer a)))))) Notice the upcased IF: the compiler cannot know that START-INDEX956 is always true if MATCH-START952 is true, so it thinks there is potential for NIL to be passes to PARSE-INTEGER. That's the warning. (I'm just assuming that start-index exists when match-start is true -- I don't know. If it does, the IF is not needed. If it does not, the IF belongs there, and you should wrap your call to PARSE-INTEGER in a WHEN.) DEBUG 2 makes type inference more stupid, so the compiler fails to see the apparent problem. Hence no warning. Cheers, -- Nikodemus |