define-struct/contract members are always annotated "no bound occurrences"
Given:
#lang racket/base
(require racket/contract)
(struct plain (a b))
(plain 1 2)
(define-struct/contract contracted ([a any/c] [b any/c]))
(contracted 1 2)
The a and b members of contracted (but not of plain) are annotated "no bound occurrences".
This is true in both Dr Racket and Racket Mode. The presentation is more obvious in Racket Mode, because by default it is configured to show unused identifiers and requires with a strikeout font (as well as showing the mouseover text). Whereas in Dr Racket you would not notice unless you mouse hover.^1
^1: In general: The fact that Racket Mode more strongly "surfaces in the UI" annotations about unused items, with a configurable font, is for some users a positive feature. At the same time, that means it is going to surface more "edge" and/or "interesting" cases, like this -- fortunately or unfortunately.
It seems to me that there are two bugs here, one in struct (and define-struct) that does not show us "no bound occurrences" in the program above and one where define-struct/contract shows "no bound occurrences" on a in this program:
#lang racket
(define-struct/contract contracted ([a any/c] [b any/c]))
(contracted-a (contracted 1 2))
Good point. Your example is better. Mine was too minimal, being too hasty trying to simplify some real-world examples. One of those would be where the accessors are provided directly or via struct-out. That should follow the idea that a definition is "used" merely by being provided.
I agree that this is also an input where things go wrong:
#lang racket
(define-struct/contract contracted ([a any/c] [b any/c]))
(contracted 1 2)
(provide contracted-a)
I guess this is the same bug, tho (and it requires a change in the define-struct/contract macro, not drracket/check-syntax).
In general: The fact that Racket Mode more strongly "surfaces in the UI" annotations about unused items, with a configurable font, is for some users a positive feature.
Very positive. Can we bring that to DrRacket as well?
@jackfirth I've generally tried to not have anything change based on when the check syntax results come back as I've feared flashing in the UI. But perhaps I should relax that a bit for something subtle, especially if we're willing to leave it there after an edit and before the next round of check syntax results come back.