-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ast: syntax errors for invalid fn invocation (#449)
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 --------- Co-authored-by: Pat Gavlin <[email protected]>
- Loading branch information
Showing
7 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
values: | ||
multiple-keys: | ||
fn::rotate::provider: | ||
inputs: {} | ||
state: | ||
ohno: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"decl": { | ||
"Description": null, | ||
"Imports": null, | ||
"Values": { | ||
"Entries": [ | ||
{ | ||
"Key": { | ||
"Value": "multiple-keys" | ||
}, | ||
"Value": { | ||
"Entries": [ | ||
{ | ||
"Key": { | ||
"Value": "fn::rotate::provider" | ||
}, | ||
"Value": { | ||
"Entries": [ | ||
{ | ||
"Key": { | ||
"Value": "inputs" | ||
}, | ||
"Value": { | ||
"Entries": [] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"Key": { | ||
"Value": "state" | ||
}, | ||
"Value": { | ||
"Entries": [ | ||
{ | ||
"Key": { | ||
"Value": "ohno" | ||
}, | ||
"Value": { | ||
"Value": true | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"diags": [ | ||
{ | ||
"Severity": 1, | ||
"Summary": "illegal call to builtin function: \"fn::rotate::provider\" must be the only key within its containing object", | ||
"Detail": "", | ||
"Subject": { | ||
"Filename": "invalid-invocation", | ||
"Start": { | ||
"Line": 3, | ||
"Column": 5, | ||
"Byte": 29 | ||
}, | ||
"End": { | ||
"Line": 6, | ||
"Column": 17, | ||
"Byte": 95 | ||
} | ||
}, | ||
"Context": null, | ||
"Expression": null, | ||
"EvalContext": null, | ||
"Extra": null, | ||
"Path": "values[\"multiple-keys\"]" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
values: | ||
fn::secret: "hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"decl": { | ||
"Description": null, | ||
"Imports": null, | ||
"Values": { | ||
"Entries": [ | ||
{ | ||
"Key": { | ||
"Value": "fn::secret" | ||
}, | ||
"Value": { | ||
"Value": "hello" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
"diags": [ | ||
{ | ||
"Severity": 1, | ||
"Summary": "builtin function call \"fn::secret\" not allowed at the top level", | ||
"Detail": "", | ||
"Subject": { | ||
"Filename": "invalid-invocation2", | ||
"Start": { | ||
"Line": 2, | ||
"Column": 3, | ||
"Byte": 10 | ||
}, | ||
"End": { | ||
"Line": 2, | ||
"Column": 13, | ||
"Byte": 20 | ||
} | ||
}, | ||
"Context": null, | ||
"Expression": null, | ||
"EvalContext": null, | ||
"Extra": null, | ||
"Path": "values[\"fn::secret\"]" | ||
} | ||
] | ||
} |