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

misleading QueryError on misspelled labels or kinds #1042

Closed
OmarTawfik opened this issue Jul 19, 2024 · 0 comments · Fixed by #1052
Closed

misleading QueryError on misspelled labels or kinds #1042

OmarTawfik opened this issue Jul 19, 2024 · 0 comments · Fixed by #1052
Assignees

Comments

@OmarTawfik
Copy link
Contributor

OmarTawfik commented Jul 19, 2024

Query::parse(
        "[FunctionDefinition
            ...
            @name Name: [_]
            ...
        ]",
    )
    .unwrap()

Error:

QueryError {
    message: "Parse error:\nexpected ']' at: @name Name: [_]\n            ...\n        ]\nAlt at: [FunctionDefinition\n            ...\n            @name Name: [_]\n            ...\n        ]\nAlt at: [FunctionDefinition\n            ...\n            @name Name: [_]\n            ...\n        ]\n",
    row: 0,
    column: 0
}
  • Query is fixed by replacing Name: with name:.
  • Same error message happens when misspelling kinds.
  • Instead of rejecting the whole identifier as an invalid nom alternative, maybe we can parse the identifier, and produce an error (at the identifier location) explaining why it is not a valid TerminalKind, NonterminalKind, or NodeLabel?
@OmarTawfik OmarTawfik changed the title misleading QueryError on misspelled labels misleading QueryError on misspelled labels or kinds Jul 19, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 2, 2024
Fixes #1041
Fixes #1042 

This PR improves on the query parse errors reported:

- Compute row and column information for query parser errors (previously
these were not computed and hard-coded to 0,0)

- Improve reporting when the error occurs attempting to parse edge
labels or node kinds: By using `cut()` and providing a `context()` we
can get a better error message without fully customizing the error type
used throughout the parser.
@github-project-automation github-project-automation bot moved this from ⏳ Todo to ✅ Done in Slang - 2024 H2 Aug 2, 2024
ggiraldez added a commit to manastech/slang that referenced this issue Aug 6, 2024
Fixes NomicFoundation#1041
Fixes NomicFoundation#1042 

This PR improves on the query parse errors reported:

- Compute row and column information for query parser errors (previously
these were not computed and hard-coded to 0,0)

- Improve reporting when the error occurs attempting to parse edge
labels or node kinds: By using `cut()` and providing a `context()` we
can get a better error message without fully customizing the error type
used throughout the parser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants