-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix directly constrained List
shape with indirectly constrained aggregate type member shape
#3894
base: main
Are you sure you want to change the base?
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
000b37a
to
a25cced
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
...ware/amazon/smithy/rust/codegen/server/smithy/generators/UnconstrainedCollectionGenerator.kt
Outdated
Show resolved
Hide resolved
""", | ||
"FinalMapping" to | ||
writable { | ||
if (constrainedValueTypeIsNotFinalType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of putting the if
statement within the writable
, can we write things in two phases and add a statement that does another pass, converting the value? Similar to how we tackle this case in UnconstrainedMapGenerator
, where we have an if (constrainedValueTypeIsNotFinalType) {
and explain within it this corner case and do a pass calling .into()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I benchmarked performing this in separate phases, as done in UnconstrainedMapGenerator
, and found it to be about 5ns slower on a vector of 4 string values. Therefore, I decided to keep this version instead of adding a second pass. I'll refactor it slightly and move the if
statement out. If that doesn’t improve readability, I’ll opt for the double pass.
dir.deleteRecursively() | ||
} | ||
|
||
// Simply compiling the crate is sufficient as a test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather move all these to constraints.smithy
, since, as noted here, simply compiling the crate is sufficient. Each of these is generating and compiling a brand new crate, which adds time. Instead, constraints.smithy
constitues a "kitchen-sink"-style test for all constraints-related things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely agreed. I should have added a TODO
here to clarify why these tests are included. There’s an earlier commit in this PR that adds them to constraints.smithy
, but our pubConstrainedTypes = false
implementation is currently incomplete and has several edge cases, causing the PR to fail. I’ve created a new issue (#3895) to document all related edge cases. I initially tried to address these within this PR but encountered cases requiring more refactoring than is feasible here.
A new generated diff is ready to view.
A new doc preview is ready to view. |
05c6e78
to
6362a0d
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
This PR fixes a bug in the code generation for a directly constrained List shape that has an indirectly constrained aggregate type as a member shape.
For example, in the following model:
A
TryFrom
implementation is generated that converts fromItemListUnconstrained
toItemList
by converting each member of the inner list ofItemUnconstrained
toItemConstrained
and then converting it toVec<Vec<ItemName>>
:Partially fixes issue: #3885 for publicly constrained shapes only.