MAP: infer return type of mapping function
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Wishlist
|
Unassigned |
Bug Description
As per https:/
There is a function mentioned in the above blog post, the full body of which is:
(defun add-text-padding (str &key padding newline)
"Add padding to text STR. Every line except for the first one, will be
prefixed with PADDING spaces. If NEWLINE is non-NIL, newline character will
be prepended to the text making it start on the next line with padding
applied to every single line."
(let ((str (if newline
(with-
(map 'string
(lambda (x)
(princ x s)
(when (char= x #\Newline)
str))))
The troublesome part is the (MAP 'STRING (LAMBDA (X) ...) STR) call. The anonymous function ends with a WHEN/DOTIMES call, which causes it to always return NIL. MAP 'STRING, in turn, requires that its function returns characters.
This information can be utilized by SBCL to emit a compile-time warning about mismatched types: the type exected by MAP and actual return type of the function.
Changed in sbcl: | |
status: | New → Triaged |
importance: | Undecided → Wishlist |
assignee: | nobody → Stas Boukarev (stassats) |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
In da13f47cceaacaf a6f4f60917032c2 cdb22add5e.