Skip to content

Conversation

john-h-kastner-aws
Copy link
Contributor

Description of changes

Improve parser error messages to more reliably notice that a function or method does exists when it is called with an incorrect number of arguments or using the wrong call style.

For example [].contains(1, 2) now gives the following error where previously it said not a valid method name: `contains` (this message was already given in the cst->est conversion, but not cst->ast).

Error:   × failed to parse policy set
  ╰─▶ call to `contains` requires exactly 1 argument, but got 2 arguments
   ╭─[<stdin>:2:1]
 2 │ 
 3 │ [].contains(1,2)
   · ───────────────
 4 │ 
   ╰────

This PR includes a similar fix for when an extension function is called as a method or an extension method is called as a function.

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 infrastructure.

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 merged commit 4816432 into main Dec 8, 2023
@cdisselkoen cdisselkoen deleted the feature/jkastner/function_errs branch December 8, 2023 20:57
@sarahcec sarahcec added the 3.1 Features for 3.1 label Jan 23, 2024
shaobo-he-aws pushed a commit that referenced this pull request May 20, 2025
Signed-off-by: Craig Disselkoen <[email protected]>
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.

4 participants