The value NIL is not of type STREAM.

Bug #598374 reported by Norbert Paul
4
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

1 I do:

  (defun my-princ (object &optional output-stream)
      (write object
             :stream output-stream
             :readably nil
             :escape nil))
  ==> MY-PRINC

  (my-princ '(hello World))

then signals a TYPE-ERROR
  The value NIL is not of type STREAM.
  (SB-PRETTY::MAKE-PRETTY-STREAM NIL)
seems that the stream designator NIL is passed
that function which expects a stream instead.

What I expect is

  (my-princ '(hello World))
  (HELLO WORLD)
  ==> (HELLO WORLD)

Just like when I do

  (write '(Hello World)
         :stream nil
         :readably nil
         :escape nil)

which indeed behaves as expected:
See also:
   CLHS 22.4 The Printer Dictionary
    -> Function WRITE, PRIN1, PRINT, PPRINT, PRINC

This problem only occurs when MY-PRINC-ing lists.
With numbers, however, there is another problem:

  (my-princ 12) ; will return a wrong value
  12
  ==> NIL

but the equivalent write expression correctly gives

  (write 12 :stream nil :readably nil :escape nil)
 12
  ==>12

2 $ sbcl --version
   SBCL 1.0.25.debian

3 $ uname -a
   Linux pc92-e03-3 2.6.32-trunk-686 #1 SMP Sun Jan 10 06:32:16 UTC 2010 i686 GNU/Linux

4 *FEATURES*
  ==> (:SB-FUTEX :SB-THREAD :ANSI-CL :COMMON-LISP :SBCL :SB-DOC :SB-TEST :SB-LDB
     :SB-PACKAGE-LOCKS :SB-UNICODE :SB-EVAL :SB-SOURCE-LOCATIONS
     :IEEE-FLOATING-POINT :X86 :UNIX :ELF :LINUX :LARGEFILE :GENCGC
     :STACK-GROWS-DOWNWARD-NOT-UPWARD :C-STACK-IS-CONTROL-STACK
     :COMPARE-AND-SWAP-VOPS :UNWIND-TO-FRAME-AND-CALL-VOP :RAW-INSTANCE-INIT-VOPS
     :STACK-ALLOCATABLE-CLOSURES :ALIEN-CALLBACKS :CYCLE-COUNTER :LINKAGE-TABLE
     :OS-PROVIDES-DLOPEN :OS-PROVIDES-PUTWC :OS-PROVIDES-SUSECONDS-T)

Revision history for this message
Stas Boukarev (stassats) wrote :

That's another problem with WRITE compiler macro (https://bugs.launchpad.net/sbcl/+bug/581564)
 I attached a patch which combines fixing the above mentioned ticket and this issue. And it fixes another issue, compiler-macro returns NIL, while it should return an object.

Revision history for this message
Stas Boukarev (stassats) wrote :

I updated the patch for the current SBCL.

Stas Boukarev (stassats)
tags: added: review
Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
Revision history for this message
Nikodemus Siivola (nikodemus) wrote :

Thank you.

Committed in 1.0.42.4.

Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
status: New → Fix Committed
tags: removed: review
Changed in sbcl:
status: Fix Committed → 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.