You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Robot's parser detects many errors already at the parsing time, but there are also many syntax errors that are only detected at the execution time. A problem with detecting errors only at the execution time is that they aren't reported to tools like editor plugins that use Robot's parser. We should thus move error detection to parser as much as possible. This includes at least these cases:
Empty test and keyword.
END, ELSE, ELSE IF, EXCEPT or FINALLY when there is no matching parent element like IF or TRY.
RETURN used in test. Fixed already in RF 5.0.
BREAK/CONTINUE outside loops. Fixed already in RF 5.0.
RETURN/BREAK/CONTINUE in FINALLY. Fixed already in RF 5.0.
We also have a similar problem that some of the error situations detected by the parser are not detected as early as they could be. For example, having IF with more than one condition is detected by the parser when the parsing model is validated, but the underlying tokens do not get ERROR type. This is a problem if only using tokens (i.e. when using get_tokens, not get_model) and also when using the model it would be more convenient if invalid tokens could be easily detected. This problem occurs at least in these cases:
IF, ELSE IF and WHILE with more than one condition.
ELSE, END, BREAK, CONTINUE, TRY and FINALLY with values.
AS with invalid variable or with more than one variable.
Because these latter errors are detected by the parser, only a bit late, I don't consider this limitation as bad as the problem with the earlier errors.
After ffa0d4e syntax errors are reported during execution using raise DataError(msg, syntax=True). All such usages are listed below and some of these could probably be detected already at parsing time:
src/robot/running/bodyrunner.py
101: error = DataError(data.error, syntax=True)
301: raise DataError('FOR loop has no loop values.', syntax=True)
348: error = DataError(data.error, syntax=True)
442: error = DataError(syntax_error, syntax=True)
510: raise DataError(data.error, syntax=True)
src/robot/running/namespace.py
289: raise DataError('Keyword name cannot be empty.', syntax=True)
291: raise DataError('Keyword name must be a string.', syntax=True)
src/robot/running/model.py
196: raise DataError(self.error, syntax=True)
218: raise DataError(self.error, syntax=True)
240: raise DataError(self.error, syntax=True)
`We also have a similar problem that some of the error situations detected by the parser are not detected as early as they could be. For example, having IF with more than one condition is detected by the parser when the parsing model is validated, but the underlying tokens do not get ERROR type. This is a problem if only using tokens (i.e. when using get_tokens, not get_model) and also when using the model it would be more convenient if invalid tokens could be easily detected. This problem occurs at least in these cases:
IF, ELSE IF and WHILE with more than one condition.
ELSE, END, BREAK, CONTINUE, TRY and FINALLY with values.
AS with invalid variable or with more than one variable.
Because these latter errors are detected by the parser, only a bit late, I don't consider this limitation as bad as the problem with the earlier errors.`
Other enhancements listed in the original post are now fixed.
Activity
yanne commentedon Mar 2, 2022
These three points are covered already in 5.0:
pekkaklarck commentedon Sep 27, 2022
After ffa0d4e syntax errors are reported during execution using
raise DataError(msg, syntax=True). All such usages are listed below and some of these could probably be detected already at parsing time:pekkaklarck commentedon Jan 3, 2023
Need to take a closer look at this and submit concrete issues about errors that could be detected earlier.
[-]Enhance errror detection at parsing time[/-][+]Enhance error detection at parsing time[/+]Detect empty tests and user keywords during parsing time
9 remaining items
parsing: dangling END, ELSE and EXCEPT are now errors in AST
parsing: do not report test/kw errors in console
parsing: lex dangling FINALLY as Error
schema: Add the new Error element
yanne commentedon Mar 14, 2023
We decided to leave this part for a later stage:
`We also have a similar problem that some of the error situations detected by the parser are not detected as early as they could be. For example, having IF with more than one condition is detected by the parser when the parsing model is validated, but the underlying tokens do not get ERROR type. This is a problem if only using tokens (i.e. when using get_tokens, not get_model) and also when using the model it would be more convenient if invalid tokens could be easily detected. This problem occurs at least in these cases:
IF, ELSE IF and WHILE with more than one condition.
ELSE, END, BREAK, CONTINUE, TRY and FINALLY with values.
AS with invalid variable or with more than one variable.
Because these latter errors are detected by the parser, only a bit late, I don't consider this limitation as bad as the problem with the earlier errors.`
Other enhancements listed in the original post are now fixed.
parsing: dangling END, ELSE and EXCEPT are now errors in AST
parsing: do not report test/kw errors in console
parsing: lex dangling FINALLY as Error
schema: Add the new Error element