Inconsistent style-warning for addition of null-adjacent values

Bug #2064761 reported by Patrick Poitras
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Invalid
Undecided
Unassigned

Bug Description

In trying to reproduce a bug (backstory in comment below) I came across this bug which yields inconsistent behavior when typechecking.

CL-USER> (defun blarg1 (value)
           (+ 2 (car value)))
BLARG1

CL-USER> (defun blarg2 (value)
           (+ 2 (when value
                  (car value))))
; in: DEFUN BLARG2
; (WHEN VALUE (CAR VALUE))
; ==>
; NIL
;
; caught STYLE-WARNING:
; This is not a NUMBER:
; NIL
; See also:
; The SBCL Manual, Node "Handling of Types"
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
BLARG2

The functions compile and execute correctly:

(blarg1 (list 5)) and (blarg2 (list 5)) both return 7.
(blarg1 nil) and (blarg2 nil) return a type-error.

The assembly emitted for these functions differs.

Reproduced on SBCL 2.3.3, SBCL 2.4.3 and SBCL 2.4.4.46-c6713be25

uname -a
Linux ppoitras-desktop-blarg 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Reproduced with *features*

(:CLPM-CLIENT :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF :OS-UNIX
 :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :ARENA-ALLOCATOR :X86-64 :GENCGC :64-BIT
 :ANSI-CL :COMMON-LISP :ELF :IEEE-FLOATING-POINT :LINUX :LITTLE-ENDIAN
 :PACKAGE-LOCAL-NICKNAMES :SB-LDB :SB-PACKAGE-LOCKS :SB-THREAD :SB-UNICODE
 :SBCL :UNIX)

and also

(:SWANK ...same features as above...)

== Note ==

This is not actively causing us issues. I'd rank it as low-priority, but I reported it anyway in the event it's a useful case to figure out weird behavior in the type checking.

Revision history for this message
Patrick Poitras (pfpoitras) wrote (last edit ):

== Unimportant context ==
The context for this bug was that

(defun blarg0 (plist)
    (destructuring-bind (&key a b c)
        plist
      (+ a b c))

used to return a style-warning under 2.3.3 and now no longer does. This difference of behavior caused me to investigate, but the cause of this particular difference in behavior is that the destructuring-bind macro now uses getf rather than sb-c::ds-getf. The latter has a structure that ressembles blarg2, and which throws the style-warning.

summary: - Inconsistent style-warning for null-adjacent values
+ Inconsistent style-warning for addition of null-adjacent values
description: updated
Revision history for this message
Stas Boukarev (stassats) wrote :

There's no bug, it does what is intended.

Changed in sbcl:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.