Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Alternative error handling for try/except fix #4208 #4210 #3075 #4211

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

Closed
wants to merge 3 commits into from
Closed

Alternative error handling for try/except fix #4208 #4210 #3075 #4211

wants to merge 3 commits into from

Conversation

d-biehl
Copy link
Contributor

@d-biehl d-biehl commented Jan 31, 2022

Referring to your comment #4209 (comment)

I tried to move the error handling for TRY/EXCEPT/ELSE/FINALLY/END into the lexer, so that errors are detected and reported as early as possible.

At the moment it is implemented in a way that the invalid tokens are reported but have no effect at runtime, similar for example if a library is not found. And I haven't corrected or created any tests yet.

In a similar way IF/WHILE/FOR could be adapted, but this should be done in separate PR's.

@pekkaklarck
Copy link
Member

pekkaklarck commented Jan 31, 2022

Using invalid number of parameters with AS, IF, etc. definitely should be a syntax error that fails execution, only reporting such errors at parsing time is not an option. To keep the usage of the parsing model easy and backwards compatible, all these errors should get available via errors attribute of the nodes in the model. Possibly it could be a property or validate() could add errors from tokens there. Either way, it must not have adverse effect for parsing performance.

Because it's unlikely these are common errors and because they are already now detected by the parser, I don't consider it too high priority to detect them earlier. I understand it's a bit better for editors to be able to highlight only the latter value in cases like

IF    $foo    $bar

instead of highlighting the whole IF node, but editors anyway need to use the latter approach in cases like

IF

where the problem is that a token is missing. I would assume it would be easier for editors to just check does the IF node have errors instead of going through each tokens. At least for Robot itself the current validation approach is simple and I'm not at all certain making it more complicated is worth the benefits. Enhancing parser to detect error that currently are only detected at the execution time (#4210) would have more benefits and would probably also be easier.

@d-biehl d-biehl closed this Feb 1, 2022
@d-biehl d-biehl deleted the alternative-fix-#4208-#4210-#3075 branch February 1, 2022 07:40
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.

2 participants