bugGuile - Bugs: bug #29817, `define*' procedures get invalid...

 
 

bug #29817: `define*' procedures get invalid source info [1.9.10]

Submitter:  Ludovic Courtès <civodul>
Submitted:  Fri 07 May 2010 09:48:31 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 05 Jun 2010 05:51:05 PM UTC, comment #1: 

Source location with IP 25 is not actually invalid, as IP 23 is actually the IP just before the tail-call; 25 is the IP afterwards, where source location info is associated. That part is correct, giving the right location for the procedure call.

The fact that there is no source location associated with the definition was a bug in which output introduced by a macro would have no source location information. Logically it actually has at least two source locations: the location of the macro definition, and that of the use.

Usually the use location is more useful, which is fortunate as we don't actually have a way to record locations in macro definitions (due to lack of needed fields in syntax objects).

So, the solution was to associate the source location of use with output introduced by the macro (i.e. define*). This has been checked into master.

Andy Wingo <wingo>
Group administrator
Fri 07 May 2010 09:48:31 AM UTC, original submission:  

Consider this procedure of one optional argument:

#v+
scheme@(guile-user)> (define* (foo #:optional y) (baz))
scheme@(guile-user)> (program-sources foo)
$25 = ((25 #f 64 . 28))
scheme@(guile-user)> ,x foo
Disassembly of #<procedure foo (#:optional y)>:

   0    (assert-nargs-ge 0 0)          
   3    (bind-optionals 0 1)           
   6    (assert-nargs-ee 0 1)          
   9    (reserve-locals 0 1)           
  12    (local-bound? 0)               
  14    (br-if :L730)                   ;; -> 21
  18    (make-false)                   
  19    (local-set 0)                   ;; `y'
  21    (toplevel-ref 1)                ;; `baz'
  23    (tail-call 0)                                         at (unknown file):64:28
#v-

Its program source info points at IP 25 whereas its last IP is 23.  In addition, it has no info associated with IP 0, which single-arity procedures always have AFAICS.

The latter is solved when using `lambda*', but not the former:

#v+
scheme@(guile-user)> (define foo (lambda* (#:optional y) (baz)))
scheme@(guile-user)> (program-sources foo)
$26 = ((0 #f 67 . 12) (25 #f 67 . 36))
scheme@(guile-user)> ,x foo
Disassembly of #<procedure foo (#:optional y)>:

   0    (assert-nargs-ge 0 0)          
   3    (bind-optionals 0 1)           
   6    (assert-nargs-ee 0 1)          
   9    (reserve-locals 0 1)           
  12    (local-bound? 0)               
  14    (br-if :L757)                   ;; -> 21
  18    (make-false)                   
  19    (local-set 0)                   ;; `y'
  21    (toplevel-ref 1)                ;; `baz'
  23    (tail-call 0)                                         at (unknown file):67:36
#v-

Finally, using `case-lambda' leads to different code, with more source info, but again with one IP off (19 instead of 17):

#v+
scheme@(guile-user)> (define foo (case-lambda (() (baz)) ((y) (baz))))
scheme@(guile-user)> (program-sources foo)
$27 = ((0 #f 70 . 12) (13 #f 70 . 29) (15 #f 70 . 12) (19 #f 70 . 41))
scheme@(guile-user)> ,x foo
Disassembly of #<procedure foo () | (y)>:

   0    (br-if-nargs-ne 0 0 :L785)      ;; -> 13
   6    (reserve-locals 0 0)           
   9    (toplevel-ref 1)                ;; `baz'
  11    (tail-call 0)                                         at (unknown file):70:29
  13    (assert-nargs-ee/locals 1)                            at (unknown file):70:12
  15    (toplevel-ref 1)                ;; `baz'
  17    (tail-call 0)                                         at (unknown file):70:41
#v-

Ludo'.

Ludovic Courtès <civodul>
Group administrator

 

(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

 

Carbon-Copy List
  • -email is unavailable- added by wingo (Posted a comment)
  • -email is unavailable- added by civodul (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-06-05 wingo StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code