wanted: FORMAT should warn on (FORMAT "FOO ~A" ...)
Bug #327223 reported by
Tobias C. Rittweiler
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
Wishlist
|
Unassigned | ||
Bug Description
I regularly forget to add T, and simply write (FORMAT "FOO ~A" ...).
Notice that a string is valid as first argument to FORMAT, that's the
reason why this isn't complained about by type inference.
Still a string literal may not be modified, so SBCL has all right to
signal a full warning in this case.
description: | updated |
Changed in sbcl: | |
importance: | Undecided → Wishlist |
status: | New → Confirmed |
Changed in sbcl: | |
assignee: | nobody → Roman Marynchak (roman-marynchak) |
tags: | added: review |
tags: | removed: review |
Changed in sbcl: | |
assignee: | Roman Marynchak (roman-marynchak) → nobody |
Changed in sbcl: | |
assignee: | nobody → Nikodemus Siivola (nikodemus) |
status: | Confirmed → In Progress |
tags: | added: pending |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
CLHS says that a string should have a fill pointer in order to be an acceptable first argument to FORMAT. So, in such a case SBCL should give a compilation error, not a warning. When a string has no fill pointer, the code will fail to execute anyway, due to SB-IMPL: :MAKE-FILL- POINTER- OUTPUT- STREAM call failure.
So it seems to me that the right way is to modify the FORMAT function info in file /src/compiler/ fndb.lisp to be like this:
(defknown format ((or (member nil t) stream
(and string (satisfies array-has- fill-pointer- p)))
(or string function) &rest t)
(or string null)
(explicit-check))
Here a string as a first argument should also pass array-has- fill-pointer- p predicate. Unfortunately, such a modification breaks the cross-compilation and SBCL goes to LDB. Is SATISFIES prohibited to use with DEFKNOWN, or I have used it in a wrong way? The LDB info is:
0: Foreign fp = 0x7ffff517c080, ra = 0x410fbf LISP::FDEFINITI ON FUNCTION- CALL-VALUE FUNCTION- CALL-VALUE FUNCTION- CALL-P
1: Foreign fp = 0x7ffff517c0b0, ra = 0x41471d
2: Foreign fp = 0x7ffff517c0f0, ra = 0x41215a
3: Foreign fp = 0x7ffff517c5a0, ra = 0x7ffff79cd080
4: (SB!C::TL-XEP COMMON-LISP::ERROR)
5: COMMON-
6: SB!C::CONSTANT-
7: SB!C::CONSTANT-
8: SB!C::CONSTANT-
9: SB!KERNEL::CTYPEP
Regards,
Roman