The behaviour of `prop:object-name` does not play well with `#:auto` fields.
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 5.2k
- Forks
- 698
- Avg merge
- 18h 34m
- Merged PRs (30d)
- 5
Description
What version of Racket are you using?
Racket 8.12 [cs]
What program did you run?
#lang racket/base
(struct thing-1 (a [b #:auto])
#:auto-value 'b
#:property prop:object-name (struct-field-index a))
(struct thing-2 (a [b #:auto])
#:auto-value 'b
#:property prop:object-name (struct-field-index b))
(object-name (thing-1 'a)) ; => 'a
(object-name (thing-2 'a)) ; => 'b (except it isn't)
What should have happened?
One would except to get back the values 'a and 'b.
If you got an error message, please include it here.
We get 'a as expected but instead of 'b we get the error:
guard-for-prop:object-name: field index >= initialized-field count for structure type
field index: 1
initialized-field count: 1
Please include any other relevant details
Looking at the racket source, It's not clear why this error happens but it does seem to be intentional. If that is the case then the correct course of action would probably be to alter the documentation of object-name to specify what kinds of fields can and cannot be used as names.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the supplied struct definitions and calls to object-name. Start by tracing the implementation of prop:object-name and its handling of initialized versus auto fields; determine whether auto fields should be supported, then update the behavior or the object-name documentation accordingly and add or run a regression test for both examples.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100