Ambiguous binding error, and trying to add generic-interface inheritance

66 views
Skip to first unread message

Alexander D. Knauth

unread,
Sep 23, 2015, 9:05:13 PM9/23/15
to Racket Users
I'm trying to add inheritance to generic interfaces:

But it's in a weird state where it's passing some of the time, (seemingly depending on how exactly I fiddle with it, compile it, restart DrRacket, and/or other things), but the other times it's giving me ambiguous binding errors like this:


pkgs/racket-test/tests/generic/extend.rkt:6:3: get: identifier's binding is ambiguous
  context...:
   #(894142 module) #(894143 module extend 0) #(895177 macro) #(895618 local)
   #(895650 intdef) #(895651 local) #(895652 intdef) #(895655 local)
   #(895656 intdef) #(895661 local) #(895663 intdef) #(895664 local)
   #(895665 intdef) #(895666 local) #(895667 intdef) #(895671 local)
   #(895673 intdef) #(895674 local) #(895675 intdef)
  matching binding...:
   local get128618
   #(894142 module) #(894143 module extend 0) #(895618 local) #(895650 intdef)
   #(895651 local) #(895652 intdef) #(895655 local) #(895656 intdef) #(895661 local)
   #(895663 intdef) #(895664 local) #(895665 intdef) #(895666 local)
   #(895667 intdef) #(895671 local) #(895673 intdef) #(895674 local)
   #(895675 intdef)
  matching binding...:
   local get128614
   #(894142 module) #(894143 module extend 0) #(895177 macro) #(895618 local)
   #(895650 intdef) #(895651 local) #(895652 intdef) #(895655 local)
   #(895656 intdef) #(895661 local) #(895663 intdef) #(895664 local)
   #(895665 intdef) #(895666 local)
  matching binding...:
   #f
   #(894142 module) #(894143 module extend 0)
  in: get
  compilation context...:
   /Users/travis/build/AlexKnauth/racket/pkgs/racket-test/tests/generic/extend.rkt
  context...:
   /Users/travis/build/AlexKnauth/racket/racket/collects/racket/private/generic-methods.rkt:161:2

I'm also getting errors from data/order.rkt, but that's a separate problem, and an easy one to fix. (I already did on my computer, but Travis is getting data/order from the package, not from my computer.)

Do you have any idea what's going on, or how to do this right?

Thanks!
Alex Knauth

Alex Knauth

unread,
Sep 24, 2015, 1:05:42 PM9/24/15
to Racket Users
I've figured out where the error is coming from, but I still have no idea what's going on.
racket/private/generic-methods.rkt starting on line 174:
(define-syntax (generic-methods stx)
    (syntax-case stx ()
      [(_ gen def ...)
       (let ()
         (define info (get-info 'generic-methods stx #'gen))
         (define orig-id (generic-info-name info))
         (define methods (map (make-method-delta #'gen orig-id)
                              (generic-info-method-names info)))
         (with-syntax ([(method ...) methods])
           (syntax/loc stx
             (syntax-parameterize ([generic-method-outer-context #'gen])
               (letrec-syntaxes+values
                ([(method) (make-unimplemented 'method)] ...)
                ()
                (syntax-parameterize ([generic-method-inner-context #'gen])
                  def ...
                  (values (implementation method) ...)))))))]))

I didn't change this code at all, but something about how I'm setting up the generic interface is causing this to give the ambiguous binding error.
I'm getting the error for get method, which came from a super interface (gen:getter), but the has? method, which comes directly from the sub interface (gen:pattern), works fine.

#lang racket/base

(require racket/generic rackunit racket/private/generic-methods
         syntax/macro-testing
         (for-syntax racket/base syntax/parse))

(define-generics getter
  (get getter target))

(define-generics pattern
  (has? pattern target)
  #:extends gen:getter)

(generic-methods
 gen:pattern
 (define (has? this target) (pair? target))) ; this works fine

(convert-compile-time-error
 (generic-methods
  gen:pattern
  (define (get this target) (car target)))) ; this gives an ambiguous binding error


Any help?

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages