bugKawa - Bugs: bug #39059, Method keywords problem

 
 

bug #39059: Method keywords problem

Submitter:  Matthieu Vachon <maoueh>
Submitted:  Fri 24 May 2013 02:23:16 AM UTC
   
 
Category:  Code generation 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
   

Sat 25 May 2013 11:56:25 PM UTC, comment #2: 

Works like a charm, thank you.

Matthieu Vachon <maoueh>
Sat 25 May 2013 07:57:42 PM UTC, comment #1: 

Oops.  This is because in LambdaExp's enterFunction we failed to increment the key_i index if the parameter is "ignorable".

I checked in a fix and test-case.

Per Bothner <bothner>
Group administrator
Fri 24 May 2013 02:23:16 AM UTC, original submission:  

I define a method taking keyword arguments, when I retrieve one without retrieving another one, the completely wrong value is returned. It looks like there is a big problem with bindings.

Take the following example:


(define (small #!key (a "default a") (b "default b") (c "default c"))
  (newline)
  (format (current-output-port) "Test small~%")
  (format (current-output-port) " A => ~a~%" a)
  ;;(format (current-output-port) " B => ~a~%" b)
  (format (current-output-port) " C => ~a~%" c))

(small a: "a" b: "b" c: "c")


It prints


Test small
 A => a
 C => b


The second line should have been "C => c". This happens in 1.12 and latest version.

Uncommenting the commented line make it works correctly though.

Also, maybe related, maybe not, using and invalid keyword works also, maybe because bindings is not done at the right index. For example, this call `(small a: "a" b: "b" invalid-c: "c")` also gives:


Test small
 A => a
 C => b


For a big test case, order is even stranger:


(define (big #!key
             (a "default a") (b "default b")
             (c "default c") (d "default d")
             (e "default e") (f "default f")
             (g "default g") (h "default h")
             (i "default i") (j "default j")
             (k "default k") (l "default l")
             (m "default m") (n "default n")
             (o "default o"))
    (newline)
  (format (current-output-port) "Test Big~%")
  (format (current-output-port) " C => ~a~%" c)
  (format (current-output-port) " D => ~a~%" d)
  (format (current-output-port) " E => ~a~%" e)
  (format (current-output-port) " F => ~a~%" f)
  (format (current-output-port) " K => ~a~%" k)
  (format (current-output-port) " L => ~a~%" l)
  (format (current-output-port) " M => ~a~%" m))

(big a: "a" b: "b" e: "e" f: "f" o: "o" n: "n" i: "i" g: "g" h: "h")


Will print the following (all wrong) output:


Test Big
 C => a
 D => b
 E => default e
 F => default f
 K => e
 L => f
 M => g


I attached my test script.

Regards,
Matt

Matthieu Vachon <maoueh>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #28154:  keywords-problem.scm added by maoueh (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bothner (Posted a comment)
  • -email is unavailable- added by maoueh (Submitted the item)
  •  

    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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-05-25 bothner CategoryNone Code generation
        Item GroupNone Unexpected result
        StatusNone Fixed
        Assigned toNone bothner
        Open/ClosedOpen Closed
    2013-05-24 maoueh Attached File- Added keywords-problem.scm, #28154

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code