racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
448 stars 95 forks source link

racket/class methods are always annotated as "no bound occurrences" #369

Open greghendershott opened 4 years ago

greghendershott commented 4 years ago

As discussed here: https://github.com/greghendershott/racket-mode/issues/440

As with #366 I'm not sure if this can/should be fixed in drracket/check-syntax as opposed to the source e.g. racket/class.

sorawee commented 4 years ago

Do we want an arrow for f in the following scenario (from define to private)?

(class object%
  (super-new)
  (private f)
  (define (f) 1))

If the answer is yes, then perhaps a solution is to add a new kind of syntax property, like disable-no-bound-occurrence. The class form should attach this syntax property, and then Check Syntax would need to be modified to skip reporting no bound occurrences when this syntax property is found.

If the answer is no, then I think we can simply change the class form to remove disappeared-binding.

sorawee commented 4 years ago

Hmm.

#lang racket

(define-syntax-rule (p x)
  (begin
    (provide x)
    (define x 1)))

(p a)

reports that a in (p a) has no bound occurrences. This p is similar to define/private because define/private similarly expands to (begin (private x) (define (x ...) ...)).

So I think there are two bugs here.

  1. Currently there is no arrow from the identifier in define to the identifier in private (in the above comment). This should be fixed so that it's similar to how there's an arrow from define to provide.
  2. For macros like define/private and p, there should be a general mechanism to detect that the identifier is "used" already in the expanded form so that it skips reporting "no bound occurrences". That means my ad-hoc solution (disable-no-bound-occurrence) doesn't look like a good idea anymore.
rfindler commented 4 years ago

For point 2 above, I think it might be fixable inside check syntax. If so, the fix would be some where in this general vicinity. It may be that the argument (connections) needs some more information it, tho, I suppose.