cedar-policy / cedar

Implementation of the Cedar Policy Language
https://www.cedarpolicy.com
Apache License 2.0
889 stars 80 forks source link

Imprecise error messages of `has` operations #1329

Open shaobo-he-aws opened 1 day ago

shaobo-he-aws commented 1 day ago

Describe the improvement you'd like to request

Consider the following ill-formed policy,

permit(principal, action, resource) when { principal has if };

The CLI reports a parsing error as follows,

  × failed to parse policy set
  ╰─▶ this identifier is reserved and cannot be used: if
   ╭────
 1 │ permit(principal, action, resource) when { principal has if };
   ·                                            ────────────────
   ╰────

The error span should ideally only cover if, as opposed to the entire has expression.

Describe alternatives you've considered

No response

Additional context

No response

Is this something that you'd be interested in working on?