Use more precise AnyList and AnyStruct in the Value schema#2501
Merged
Conversation
kentonv
reviewed
Jan 12, 2026
This changes Value.list and Value.struct from AnyPointer to its narrower counterparts. This improves type safety for external codegens, but of course requires some changes in C++ as well. In particular, I'm not 100% sure about my `getValuePointer` approach to getting the default value as non-dereferenced raw pointer again after this change, if there's a better way, I'm happy to change it. As far as I can tell, this schema change is backward-compatible and no renumbering is necessary.
This prevents them being expanded in diffs by default, which makes diffs easier to read.
534840f to
ccb03de
Compare
Contributor
Author
|
Btw another alternative to this PR could be to eliminate struct/list/interface variants from Or vice versa, remove But I guess it's too much of a breaking change either way. |
kentonv
approved these changes
May 5, 2026
pull Bot
pushed a commit
to kokizzu/cloudflare-workerd
that referenced
this pull request
May 11, 2026
capnproto/capnproto#2501 introduced a source-breaking change: schema::Value::Reader::getStruct() now returns capnp::AnyStruct::Reader (with as<T>()) instead of capnp::AnyPointer::Reader (with getAs<T>()). Bump capnp-cpp past it and update the two getStruct().getAs<T>() callers in compatibility-date.{c++,-test.c++} to use as<T>(). Assisted-by: OpenCode:claude-opus-4.7
meefs
pushed a commit
to meefs/workerd
that referenced
this pull request
Jun 1, 2026
capnproto/capnproto#2501 introduced a source-breaking change: schema::Value::Reader::getStruct() now returns capnp::AnyStruct::Reader (with as<T>()) instead of capnp::AnyPointer::Reader (with getAs<T>()). Bump capnp-cpp past it and update the two getStruct().getAs<T>() callers in compatibility-date.{c++,-test.c++} to use as<T>(). Assisted-by: OpenCode:claude-opus-4.7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This changes Value.list and Value.struct from AnyPointer to its narrower counterparts.
This improves type safety for external codegens, but of course requires some changes in C++ as well. In particular, I'm not 100% sure about my
getValuePointerapproach to getting the default value as non-dereferenced raw pointer again after this change, if there's a better way, I'm happy to change it.As far as I can tell, this schema change is backward-compatible and no renumbering is necessary.