cedar-policy / cedar

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

Suggest function in unknown extension function errors #1280

Closed adpaco-aws closed 4 weeks ago

adpaco-aws commented 1 month ago

Description of changes

This PR extends unknown function errors with a hint that suggests the closest function from the ones available based on the fuzzy string matching algorithm used to make similar suggestions. With this change, the example in #332 now also shows the help message Did you mean `ip`? in its diagnostics.

Resolves #332

Callouts

This PR does not deal with #246, a similar request for methods instead of functions. But I'm planning on fixing it right after this one's cleared.

Checklist for requesting a review

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

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

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

I confirm that docs.cedarpolicy.com (choose one, and delete the other options):