bugKawa - Bugs: bug #15579, append-map may destroy arguments.

 
 

bug #15579: append-map may destroy arguments.

Submitter:  None
Submitted:  Mon 30 Jan 2006 08:06:59 PM UTC
   
 
Category:  Scheme library Severity:  3 - Normal
Item Group:  Unexpected result Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 16 Mar 2006 05:56:43 AM UTC, comment #4: 

I checked in to CVS the fix for this.

Per Bothner <bothner>
Group administrator
Thu 09 Mar 2006 11:22:47 PM UTC, comment #3: 

Try replacing append-map and append-map! in srfi1.scm with these:

(define (append-map f lis1 . lists)
  (if (pair? lists)
      (apply append (apply map f lis1 lists))
      (apply append (map f lis1))))

(define (append-map! f lis1 . lists)
  (if (pair? lists)
      (apply append! (apply map f lis1 lists))
      (apply append! (map f lis1))))

Per Bothner <bothner>
Group administrator
Thu 09 Mar 2006 06:14:43 AM UTC, comment #2: 

But the problem is not a set-car! on a constant.  The
problem is append-map assuming that the value
returned by the function will not be used again.  Consider:

(append-map (lambda (x) (hash-table-ref/default ht x '())) ls)

I don't want the values on my hash table to be modified
by append-map, and all those values are created with
cons, not quote.

Anonymous
Sat 11 Feb 2006 01:56:16 AM UTC, comment #1: 

Well, it's not really a Kawa bug - the test program is not a well-defined program.  It's just like:
  (define p '(3 4))
  (set-car! p 5)

Ideally, Kawa should throw an exception when you attempt to set-car! on a "constant" pair.  That will probably happen in the not too distant future.

Per Bothner <bothner>
Group administrator
Mon 30 Jan 2006 08:06:59 PM UTC, original submission:  

I found a bug while using KAWA-1.8.

If you run the below program, you can see that the program does not return at 2nd append-map call. I think the reason of this is that the constants in foo are destroyed by append! in append-map.

(require 'list-lib)

(define (foo x)
  (cond ((= x 0) '(a))
        ((= x 1) '(b))
        (else '())))

; It is ok.
(append-map foo '(0 1 2))

; But it does not return.
(append-map foo '(0 1 2))

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follow 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-03-16 bothner StatusConfirmed Fixed
    Open/ClosedOpen Closed
2006-03-09 bothner StatusNone Confirmed
    Assigned toNone bothner

Back to the top

Powered by Savane 3.13-4b48.
Corresponding source code