racket / racket/racket

The behaviour of `prop:object-name` does not play well with `#:auto` fields.

Open
#4,940 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.