![]() This PR fixes four bugs: 1. Accessors are required at use-site in order to use `struct-copy`. This PR removes that requirement since the information is already available in struct-info. The following program used to fail prior the PR but will now pass. ``` (module a racket (provide a) (struct a (b))) (require 'a) (struct-copy a (a 1) [b 2]) ``` 2. `struct-copy` fails if the structure type transformer binding is renamed (#1399). The following program used to fail prior the PR but will now pass. ``` (module struct racket/base (provide (struct-out point)) (struct point (x y) #:transparent)) (require (rename-in 'struct [point point2d])) (struct-copy point2d (point2d 1 2) [x 3]) ``` 3. With supertype, it's possible to construct colliding accessors, causing `struct-copy` to update an incorrect field. The following program produced incorrect outputs prior this PR but will now be correct. ``` (module a racket (provide a) (struct a (b-c) #:transparent)) (require 'a) (struct a-b a (c) #:transparent) (struct-copy a-b (a-b 1 2) [b-c #:parent a 10]) ;; before the PR: (a-b 1 10), after the PR: (a-b 10 2) (struct-copy a-b (a-b 1 2) [c 10]) ;; before the PR: (a-b 1 10), after the PR: (a-b 1 10) ``` 4. Similar to 3., prior this commit, it's possible to refer to a bogus field name when supertype is present. The following program doesn't result in a syntax error which is wrong. This commit fixes that. ``` (module a racket/base (provide (all-defined-out)) (struct a (b-c) #:transparent)) (require 'a) (struct a-b a (d) #:transparent) (struct-copy a-b (a-b 1 2) [c 10]) ``` The key idea is that the actual struct name (if the struct is created via `struct` or `define-struct`) can be extracted from the name of struct predicate. The actual field names then can be precisely extracted from accessors. Note that struct-infos that are created manually by `make-struct-info` didn't work with `struct-copy`. This PR didn't attempt to fix that because it requires a significant change that would not be backward compatible with the current struct info. |
||
---|---|---|
.github | ||
pkgs | ||
racket | ||
.gitattributes | ||
.gitignore | ||
.mailmap | ||
build.md | ||
LICENSE | ||
Makefile | ||
README.md |
Racket is a general-purpose programming language and an ecosystem for language-oriented programming.
This repository holds the source code for the core of Racket plus some related packages. The rest of the Racket distribution source code is in other repositories, mostly under the Racket GitHub organization.
Quick Start
Pre-built versions of Racket for a variety of operating systems and architectures, as well as convenient source distributions are available at
https://download.racket-lang.org
Racket comes with extensive documentation, including several tutorials. You can read all of this documentation, as well as documentation for third-party packages at
Building from Source
For information on building Racket from this repository, see the Build Guide.
Contributing
Contribute to Racket by submitting a pull request, reporting an issue, joining the development mailing list, or visiting the IRC or Slack channels.
By making a contribution, you are agreeing that your contribution is licensed under the Apache 2.0 and MIT licenses. Those licenses are available in this repository in the files LICENSE-APACHE.txt and LICENSE-MIT.txt.
License
Racket is free software; see LICENSE for more details.