generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Labels
feature-requestThis issue requets a substantial new featureThis issue requets a substantial new feature
Description
Category
Other
Describe the feature you'd like to request
An unexpected token causes the parser to emit an error message listing every token in would have accepted in that position.
E.g., on permit(principal, action, resource;
(missing the closing paren) the error text is
Error: cedar_policy_core::parser::to_cst_error
× unexpected token `;`
╭─[a.cedar:1:1]
1 │ permit(principal, action resource;
· ┬
· ╰── expected `!=`, `%`, `&&`, `(`, `)`, `*`, `+`, `,`, `-`, `.`, `/`, `:`, `::`, `<`, `<=`, `==`, `>`, `>=`, `[`, `]`, `{`, `||`, `}`, `else`, `has`, `in`, `like`, or `then`
╰────
The list of expected tokens isn't helpful, and potentially makes the error more confusing that it would be otherwise.
This was brought up recently due to a schema parsing error in #149 where this sort of overly verbose error was caused by an empty string used for an entity type name.
Some solutions that come to mind:
- Expand what tokens the parer expects so that more error reporting can be handled in CST -> AST conversion where we have full control over error messages and can inspect the surrounding CST to generate better errors.
- Restrict what tokens the parser expects so that there will be fewer tokens in the expected tokens list.
- Hide the long token lists. Maybe they're confusing enough that it makes sense to hide it altogether.
shaobo-he-aws
Metadata
Metadata
Assignees
Labels
feature-requestThis issue requets a substantial new featureThis issue requets a substantial new feature