Skip to content

Add an optional parameter to Shape::add_dimensions() in indicate whether the dimension is dynamic. #25334

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

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

copybara-service[bot]
Copy link

Add an optional parameter to Shape::add_dimensions() in indicate whether the dimension is dynamic.

Currently, add_dimensions() doesn't validate the dimension size and assumes that the dimension is static. This may result in a Shape object that doesn't match the author's intention or break the Shape object's invariants. E.g.

  • If the author wants a dynamic dimension of size 5, add_dimensions(5) will create a static dimension of size 5. The author must remember to immediately set the dimension to be dynamic. This is error-prone.
  • add_dimensions(kUnboundedSize) results in a static dimension of size kUnboundedSize, which is invalid.

With the new is_dynamic parameter, callers can explicitly express their intention, and add_dimensions() can validate the arguments to increase safety.

@copybara-service copybara-service bot force-pushed the test_748314466 branch 6 times, most recently from 1dcbc2c to 608ba69 Compare April 17, 2025 20:27
…ether the dimension is dynamic.

Currently, `add_dimensions()` doesn't validate the dimension size and assumes that the dimension is static. This may result in a `Shape` object that doesn't match the author's intention or break the `Shape` object's invariants. E.g.

- If the author wants a *dynamic* dimension of size 5, `add_dimensions(5)` will create a *static* dimension of size 5. The author must remember to immediately set the dimension to be dynamic. This is error-prone.
- `add_dimensions(kUnboundedSize)` results in a *static* dimension of size `kUnboundedSize`, which is invalid.

With the new `is_dynamic` parameter, callers can explicitly express their intention, and `add_dimensions()` can validate the arguments to increase safety.

PiperOrigin-RevId: 748840578
@copybara-service copybara-service bot merged commit 8f4e499 into main Apr 17, 2025
1 check passed
@copybara-service copybara-service bot deleted the test_748314466 branch April 17, 2025 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant