Opened 10 years ago

Closed 10 years ago

#342 closed defect (fixed)

missing default method for gray-streams:stream-finish-output

Reported by: Anton Vodonosov Owned by:
Priority: major Milestone: 1.3.0
Component: streams Version: 1.3.0-dev
Keywords: has-patch has-test Cc:
Parent Tickets:

Description

Test case:

(ql:quickload :flexi-streams)

(let* ((binary-stream (flexi-streams:make-in-memory-output-stream)))
  (finish-output binary-stream))

The value #<FLEXI-STREAMS::VECTOR-OUTPUT-STREAM {1E566F3}> is not of type #<STANDARD-CLASS FLEXI-STREAMS:FLEXI-OUTPUT-STREAM {7D84CE}>.
   [Condition of type SIMPLE-TYPE-ERROR]

Backtrace:
  0: (#<FUNCTION {1C9E6C0}> #<SIMPLE-TYPE-ERROR {FC82A6}> #<FUNCTION {1C9E6C0}>)
  1: (APPLY #<FUNCTION {1C9E6C0}> (#<SIMPLE-TYPE-ERROR {FC82A6}> #<FUNCTION {1C9E6C0}>))
  2: (SYSTEM::RUN-HOOK SYSTEM::*INVOKE-DEBUGGER-HOOK* #<SIMPLE-TYPE-ERROR {FC82A6}> #<FUNCTION {1C9E6C0}>)
  3: (INVOKE-DEBUGGER #<SIMPLE-TYPE-ERROR {FC82A6}>)
  4: (GRAY-STREAMS:STREAM-FINISH-OUTPUT #<FLEXI-STREAMS::VECTOR-OUTPUT-STREAM {1E566F3}>)
  5: (SYSTEM::%FINISH-OUTPUT #<FLEXI-STREAMS::VECTOR-OUTPUT-STREAM {1E566F3}>)
  6: (FINISH-OUTPUT #<FLEXI-STREAMS::VECTOR-OUTPUT-STREAM {1E566F3}>)

This happens because there is no default method for stream-finish-output.
According to the Gray proposal, default method should exist and do nothing.

The fix:

Index: src/org/armedbear/lisp/gray-streams.lisp
===================================================================
--- src/org/armedbear/lisp/gray-streams.lisp    (revision 14464)
+++ src/org/armedbear/lisp/gray-streams.lisp    (working copy)
@@ -314,6 +314,10 @@
   (declare (ignore stream))
   nil)

+(defmethod stream-finish-output (stream)
+  (declare (ignore stream))
+  nil)
+
 (defmethod stream-clear-output (stream)
   (declare (ignore stream))
   nil)

Also, ABCL handles the absence of default method not very correctly.
It should signal "no applicable method". What happens here is that flexi-streams overrides
stream-finish-output for one of its classes - FLEXI-STREAMS:FLEXI-OUTPUT-STREAM.
So, I think ABCL sees that there is only one variant of method,
and tries to apply this method, despite we pass object of another class.
And here typecast happen.

Change History (7)

comment:1 Changed 10 years ago by Mark Evenson

Keywords: has-patch has-test added
Milestone: 1.3.0

comment:2 Changed 10 years ago by Mark Evenson

With patch the ansi-compiled tests fail:

The value &REST is not of type FIXNUM.
   [Condition of type TYPE-ERROR]
Backtrace:
  0: (#<FUNCTION {2CBEE72C}> #<TYPE-ERROR {5A80EE6E}> #<FUNCTION {2CBEE72C}>)
  1: (APPLY #<FUNCTION {2CBEE72C}> (#<TYPE-ERROR {5A80EE6E}> #<FUNCTION {2CBEE72C}>))
  2: (SYSTEM::RUN-HOOK SYSTEM::*INVOKE-DEBUGGER-HOOK* #<TYPE-ERROR {5A80EE6E}> #<FUNCTION {2CBEE72C}>)
  3: (INVOKE-DEBUGGER #<TYPE-ERROR {5A80EE6E}>)
  4: org.armedbear.lisp.Lisp.error(Lisp.java:382)
  5: org.armedbear.lisp.Lisp.type_error(Lisp.java:435)
  6: org.armedbear.lisp.Fixnum.getValue(Fixnum.java:293)
  7: org.armedbear.lisp.LispCharacter$6.execute(LispCharacter.java:350)
  8: org.arme

comment:3 Changed 10 years ago by Anton Vodonosov

That's very strange. How to can I run this test?

comment:4 Changed 10 years ago by Anton Vodonosov

Ok, I found how to run the tests:

ant -Dabcl.build.incremental=true test.ansi.compiled

comment:5 Changed 10 years ago by Anton Vodonosov

For me, with or without the patch, ant test.ansi.compiled gives the same result:

12 out of 21707 total tests failed:
(CALL-NEXT-METHOD.ERROR.1
CALL-NEXT-METHOD.ERROR.2
MAKE-CONDITION.3
MAKE-CONDITION.4
SXHASH.8
MAP.48
TYPE-OF.1
TYPE-OF.4
MAKE-CONCATENATED-STREAM.30
PRINT.RANDOM-STATE.1
PPRINT-LOGICAL-BLOCK.17
TRACE.8)

Tested on SVN revision 14464

comment:6 Changed 10 years ago by Mark Evenson

After redoing my compilation/test environment from scratch, my error has disappeared.

Committed as part of r14605

comment:7 Changed 10 years ago by Mark Evenson

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.