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

 
 

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

Submitted by:  Ludovic Courtès <civodul>
Submitted on:  Fri 07 May 2010 09:48:31 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project 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>
Project Administrator

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by wingo (Posted a comment)
  • -unavailable- added by civodul (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 05 Jun 2010 05:51:05 PM UTCwingoStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1