Improve missing parameter override error - #1324
Conversation
Report the expected name:=value form when a parameter override lacks assignment syntax instead of exposing lexer token internals. Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
|
Tick the box to add this pull request to the merge queue (same as
|
|
|
||
| ret = rcl_lexer_lookahead2_expect(&lex_lookahead, RCL_LEXEME_SEPARATOR, NULL, NULL); | ||
| if (RCL_RET_WRONG_LEXEME == ret) { | ||
| rcl_reset_error(); |
There was a problem hiding this comment.
this would (acutally does) delete the error messages provided by underlying implementation.
i think what we should do here is capture the error, reset the buffer, and then set a new formatted message that includes the previous error as context.
There was a problem hiding this comment.
Addressed in dd4b6e7. The parser now captures the lexer error before resetting it, then includes that diagnostic as context in the parameter override format message. The regression test checks for both the user-facing guidance and the underlying lexer error.
There was a problem hiding this comment.
Follow-up: the initial revision only covered the separator path. The updated change also routes errors reported by _rcl_parse_param_name() through the same context-preserving wrapper.
I verified the updated commit (ff95ccd) in a Rolling container: test_arguments passed, and all 52 CTest entries passed with 0 failures. The test binary was confirmed to load the locally built /tmp/colcon_ws/build/rcl/librcl.so.
Keep the underlying lexer diagnostic when adding the user-facing parameter override format guidance. Extend the regression test to require both messages. Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
Description
A parameter override such as
-p blacurrently exposes the internal lexer diagnosticExpected lexeme type (22), which does not tell the user that the assignment syntax is missing.Translate the separator parse failure at the parameter-rule parser layer into the expected
name:=valueform. Keep the existing outer argument context, return codes, and all other invalid-rule diagnostics unchanged. Add a regression test through the publicrcl_parse_arguments()entry point.Addresses the diagnostic portion of #1001.
Is this user-facing behavior change?
Yes. Invalid parameter overrides that omit
:=valuenow report the expected rule format instead of a lexer token number.Did you use Generative AI?
Yes. OpenAI Codex assisted with root-cause analysis and preparing the focused code and regression test. I reviewed the diff and verification results.
Additional Information
Local verification:
RCL_RET_INVALID_PARAM_RULEgit diff --checkThe native
test_argumentsgtest requires the ROS 2 build dependencies and CMake/colcon tooling, which are not installed on this Windows host; repository CI covers the regression test.