Using MULTIPLE-VALUE-CALL as a conditional in IF can lead to unnecessary STYLE-WARNINGs due to type propagation

Bug #750797 reported by Jean-Philippe Paradis on 2011-04-04
This bug report is a duplicate of:  Bug #309115: inline-expansion and type-inference. Edit Remove
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

What I do:
(let ((cachep :empty))
   (if (multiple-value-call #'(lambda (flag)
                                (ecase flag
                                  (:full t)
                                  (:empty nil)))

What happens:
"This is not a NUMBER: NOT-A-NUMBER"

What I expected to happen:
Since the branch that would eventually result in an error is never actually taken, I shouldn't get a warning.

Note that replacing the MULTIPLE-VALUE-CALL with FUNCALL solves the problem, which hints that this really is a bug and that MULTIPLE-VALUE-CALL is the culprit.

SBCL version: 1.0.42
uname -a: Linux dynamorph 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:21 UTC 2011 i686 GNU/Linux


Nikodemus Siivola (nikodemus) wrote :

Not a MULTIPLE-VALUE-CALL issue, really -- just plain old type inference.

CL-USER> (compile nil `(lambda (x) (+ 1 (if x 1 :not-a-number))))
; in: LAMBDA (X)
; (+ 1
; (IF X
; 1
; note: deleting unreachable code
; caught WARNING:
; Asserted type NUMBER conflicts with derived type
; See also:
; The SBCL Manual, Node "Handling of Types"
; compilation unit finished
; caught 1 WARNING condition
; printed 1 note
#<FUNCTION (LAMBDA (X)) {1002C8F649}>

In your example the difference between MULTIPLE-VALUE-CALL and FUNCALL is due to SBCL's current inability to use type inference with MULTIPLE-VALUE-CALL -- so the IF is not eliminated as it cannot prove that the NOT-A-NUMBER case never happens.

For clarity's sake I'm marking this a duplicate of

Nikodemus Siivola (nikodemus) wrote :

Um, duplicate of bug 309115. See also bug 309113.

Nikodemus Siivola (nikodemus) wrote :

Also pulled the non-optimization of MVC into its own bug 753803.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers