cedar-policy/cedar

Imprecise error messages of `has` operations

Closed this issue · 1 comments

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?

  • 👋 I may be able to implement this internal improvement
  • ⚠️ This feature might incur a breaking change

Fixed by #1327