sb-cltl2:function-information does not return ftype info for struct functions.

Bug #1934859 reported by SATO shinichi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

Actually, this is not a bug, just wishes.

* (defstruct s (slot :dummy :type keyword :read-only t))
S

* (sb-cltl2:function-information 's-slot)
:FUNCTION
NIL
NIL ; <--- no ftype information.

* (sb-cltl2:function-information 'make-s)
:FUNCTION
NIL
NIL

* (sb-cltl2:function-information 's-p)
:FUNCTION
NIL
NIL

* (sb-cltl2:function-information 'copy-s)
:FUNCTION
NIL
NIL

* (sb-int:info :function :where-from 's-slot)
:DEFINED ; <--- Not :declared
T

After explicitly DECLAIMed, all works fine as expected.

* (declaim (ftype (function (s) (values keyword &optional)) s-slot))
(S-SLOT)

* (sb-int:info :function :where-from 's-slot)
:DECLARED
T

* (sb-cltl2:function-information 's-slot)
:FUNCTION
NIL
((FTYPE FUNCTION (S) (VALUES KEYWORD &OPTIONAL))) ; <--- Got!

So I think DEFSTRUCT should generate DECLAIM automatically.
But I found the comment in the sb-int:global-ftype that says

;; In the absence of global info for a defstruct snippet, get the compiler's
;; opinion based on the defstruct definition, rather than reflecting on the
;; current function (as defined "now") which is what globaldb would get in
;; effect by calling FTYPE-FROM-FDEFN, that being less precise.

I do not know well where is the place to fix it.

* DEFSTRUCT generates DECLAIM form.
* CLTL2-FUNCTION-INFORMATION which uses global-ftype handles return value of sb-int:info.
* Fix return value of SB-INT:INFO for structure functions.

In the first case, accessor-definitiions and !expander-for-defstruct may the place to insert DECLAIM form.
Additionally global-ftype may be affected because sb-int:info returns t as the second value for the declaimed function.
The clause will never be reached. (?)

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

Other bug subscribers