Skip to content

Conversation

khieta
Copy link
Contributor

@khieta khieta commented May 23, 2024

Description of changes

Another round of edits to the parsing-related errors. I expect to make more changes to the public API in a future PR (in particular: I think we want to better hide the terms "AST" and "CST" in the public API).

  • [Affects public API] Added pub use for RestrictedExpressionParseError and ParseError, which could previously be returned by public functions, but were never exported themselves 😅 Added "CAUTION" notes to these error types like the ones added in Align EvaluationError and ExtensionFunctionLookupError with cedar#745 #860.
  • Removed the ParseLiteral and RestrictedExpr cases from ParseError. RestrictedExpr::from_str() and Literal::from_str() now have their own error types.
  • Updated the error message for UnescapeErrors to not print the EscapeError variant (which comes from Rust's lexer).

Issue #, if available

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

  • A breaking change requiring a major version bump to cedar-policy (e.g., changes to the signature of an existing API).

(This PR will be batched with the other breaking changes that are part of #745.)

I confirm that this PR (choose one, and delete the other options):

  • Does not update the CHANGELOG because my change does not significantly impact released code.

I confirm that cedar-spec (choose one, and delete the other options):

  • Does not require updates because my change does not impact the Cedar formal model or DRT infrastructure.

Comment on lines +671 to 674
// Don't make fields `pub`, don't make breaking changes, and use caution when
// adding public methods.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct ParseErrors(pub Vec<ParseError>);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Don't make fields pub" is confusing when the type already has a pub field

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should have this field be pub(crate) instead of pub, now that it's publically exported? Or should this type be an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to pub(crate) in the latest commit. I plan to make the field private in a future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought... undid this in the latest commit since I don't want to fix the resulting build failures. I promise that I'll take care of it in a PR in the next few days!

@khieta khieta force-pushed the khieta/more-parse-err-nits branch from 4b6d64c to 871a800 Compare May 23, 2024 18:49
@khieta khieta merged commit 1dc1ded into main May 23, 2024
@khieta khieta deleted the khieta/more-parse-err-nits branch May 23, 2024 19:02
@khieta khieta added the breaking-change This is (likely) a breaking change label May 23, 2024
@khieta khieta mentioned this pull request Jun 11, 2024
3 tasks
@khieta khieta mentioned this pull request Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This is (likely) a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants