Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ast: syntax errors for invalid fn invocation #449

Merged
merged 5 commits into from
Feb 20, 2025

Conversation

nyobe
Copy link
Contributor

@nyobe nyobe commented Feb 18, 2025

Currently when a fn expr is invalid we fall back to parsing it as an object, which results in an object containing a fn:: key, which is otherwise illegal, instead of the expected call. This PR makes these incorrect usages emit syntax errors so that it's easier for the user to identify the mistake ahead of time, instead of after discovering that the function wasn't called.

Case 1 - having an additional key in a fn call:

values:
  foo:
    fn::builtin: ...
    anotherKey: "oops"

Case 2 - having a fn:: key as a toplevel key in values:

values:
  fn::open::provider: ...

Resolves #447

@nyobe nyobe force-pushed the claire/syntax-errors-for-invalid-fn-invocation branch from a363467 to 0b132e4 Compare February 18, 2025 21:25
@nyobe nyobe marked this pull request as ready for review February 18, 2025 21:25
@nyobe nyobe requested review from pgavlin and seanyeh February 18, 2025 21:29
@nyobe nyobe force-pushed the claire/syntax-errors-for-invalid-fn-invocation branch from 6a3bdc2 to 7425227 Compare February 19, 2025 19:17
@nyobe nyobe force-pushed the claire/syntax-errors-for-invalid-fn-invocation branch from de7eb74 to 94b20cf Compare February 19, 2025 23:46
@nyobe nyobe merged commit 6e2c31a into main Feb 20, 2025
6 checks passed
@nyobe nyobe deleted the claire/syntax-errors-for-invalid-fn-invocation branch February 20, 2025 00:01
nyobe added a commit that referenced this pull request Feb 27, 2025
The import loader accidentally returns a nil environment if it fails to parse. Ordinarily this shouldn't happen because we don't let you save an environment if it fails validation. However, #449 introduced syntax errors for invalid fn calls, so some environments that previously incorrectly validated will now fail, and if you import one of these environments, we panic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider making fn:: directly under values and fn::s with sibling keys syntax errors
2 participants