code-char doesn't return nil on failure

Bug #63701 reported by Fat and Bold
2
Affects Status Importance Assigned to Milestone
sbcl (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

The HyperSpec entry for code-char [1] reads:

"Returns a character with the code attribute given by code. If no such character exists and one cannot be created, nil is returned."

On the following code, however, a STREAM-ENCODING-ERROR is signaled instead of nil being returned:

This is SBCL 0.9.8, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (code-char (1- char-code-limit))

debugger invoked on a SB-INT:STREAM-ENCODING-ERROR in thread
#<THREAD "initial thread" {A7BE341}>:
  encoding error on stream #<SB-SYS:FD-STREAM for "standard output" {A7BE591}>
  (:EXTERNAL-FORMAT :ASCII):
    the character with code 1114111 cannot be encoded.

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [OUTPUT-NOTHING] Skip output of this character.
  1: [ABORT ] Exit debugger, returning to top level.

(SB-INT:STREAM-ENCODING-ERROR
 #<SB-SYS:FD-STREAM for "standard output" {A7BE591}>
 1114111)
0]

This bug causes FiveAM [2] to break SLIME [3] when using its gen-character and gen-string generators.

[1] http://www.lisp.org/HyperSpec/Body/fun_code-char.html#code-char
[2] http://common-lisp.net/project/bese/FiveAM.html
[3] http://common-lisp.net/project/slime/

Revision history for this message
Peter Van Eynde (ubuntu-pvaneynd) wrote :

0.9.17 now does the right thing:

$ sbcl
This is SBCL 0.9.17, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (code-char (1- char-code-limit))

#\U0010FFFF

Revision history for this message
Fat and Bold (uk6q6zh02) wrote :

Great, I'm glad it's been fixed. Thanks.

Changed in sbcl:
status: Unconfirmed → Fix Released
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.