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

refactor: handle parsing errors with BadExpressions over panics #2804

Merged
merged 1 commit into from
May 8, 2020

Conversation

bthesorceror
Copy link
Contributor

No description provided.

Copy link
Contributor

@jsteenb2 jsteenb2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, bye bye panics

Copy link
Contributor

@adrian-thurston adrian-thurston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Just wondering if those parse functions will need to be exposed at some point? If not, could they not be returning expression directly?

Also wondering what the cases were that tripped the parse failures, which then became panics? Overflow probably one ... but are there others? Would be nice to categorize the errors, otherwise our language definition is just borrowing from rust's definition for these parse functions and we have bound ourselves to a specific implementation.

@bthesorceror bthesorceror force-pushed the bad-expression-handling branch from 8059721 to d9d57c4 Compare May 7, 2020 23:45
@bthesorceror
Copy link
Contributor Author

@adrian-thurston I've added a test around this to illuminate where we were seeing the panic in the LSP.

@bthesorceror bthesorceror force-pushed the bad-expression-handling branch from d9d57c4 to 337b823 Compare May 7, 2020 23:54
@adrian-thurston
Copy link
Contributor

@bthesorceror Okay thanks. At first I thought this was a regression in the rust parser because the scanner allows for a time literal with no timezone information on the end. But it looks like the go parser does the same ... allows the missing timezone in the scanner and fails during the RFC3339 parse. Perhaps it is to get more detailed error information, other than "scanner failed".

@nathanielc
Copy link
Contributor

Yes, the SPEC states that we support those shorter formats https://github.com/influxdata/flux/blob/master/docs/SPEC.md#date-and-time-literals but we have not implemented them yet. See #152 although it seems that the scanner supports those formats, just not the parser.

So for now we can just improve the error message to say something like shorthand time literals are not implemented yet.

@bthesorceror bthesorceror merged commit 840a526 into master May 8, 2020
@bthesorceror bthesorceror deleted the bad-expression-handling branch May 8, 2020 16:26
@adrian-thurston
Copy link
Contributor

Ah okay, thank you for the background @nathanielc

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.

4 participants