Skip to content

Conversation

john-h-kastner-aws
Copy link
Contributor

Description of changes

Fix #465. Add source information to errors found durring CST to AST conversion.

For example, the underlined source snippet in this error message:

john:cedar $ cargo run check-parse <<<'permit(principal == My-User::"alice", action, resource);'
Error:   × failed to parse policy set
  ╰─▶ expected an entity uid or matching template slot, found a `+/-` expression
   ╭─[<stdin>:1:1]
 1 │ permit(principal == My-User::"alice", action, resource);
   ·                     ────────────────
   ╰────
  help: entity types and namespaces cannot use `+` or `-` characters -- perhaps try `_` or `::` instead?

Checklist for requesting a review

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

  • A bug fix or other functionality change requiring a patch to cedar-policy.

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

  • Updates the "Unreleased" section of the CHANGELOG with a description of my change (required for major/minor version bumps).

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

  • Does not require updates because my change does not impact the Cedar Dafny model or DRT

Disclaimer

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@john-h-kastner-aws john-h-kastner-aws changed the title Feature/jkastner/cst err loc Add soure ranges to CST->AST errors Dec 7, 2023
@shaobo-he-aws
Copy link
Contributor

Should it updated after #470 is merged first?

@cdisselkoen
Copy link
Contributor

@shaobo-he-aws asks

Should it updated after #470 is merged first?

I think this is more complicated/intricate than #470, so it makes sense to merge this first, and I will update #470 accordingly. (basically applying the transformation in #470 to all of the code introduced in this PR)

@john-h-kastner-aws john-h-kastner-aws merged commit 9ee0a14 into main Dec 7, 2023
@cdisselkoen cdisselkoen deleted the feature/jkastner/cst_err_loc branch December 7, 2023 22:16
@cdisselkoen cdisselkoen added the 3.1 Features for 3.1 label Feb 6, 2024
shaobo-he-aws pushed a commit that referenced this pull request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.1 Features for 3.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include source location information in CST->AST errors
4 participants