Skip to content

Make boolean literal parsing case-insensitive - #339

Open
althea28 wants to merge 1 commit into
RosLibRust:masterfrom
althea28:update-bool-parsing
Open

Make boolean literal parsing case-insensitive#339
althea28 wants to merge 1 commit into
RosLibRust:masterfrom
althea28:update-bool-parsing

Conversation

@althea28

Copy link
Copy Markdown

Description

Make boolean literal parsing case-insensitive to match official rosidl_adapter.

Currently, roslibrust_codegen cannot parse .msg and .action files that contain capitalized boolean literals (e.g., bool success True). This causes serde_json::from_str to panic with "expected value at line XX column XX".

The official ROS 2 Python parser (rosidl_adapter/parser.py) parses boolean constants case-insensitively by converting the string to lowercase first: if value_string.lower() not in (true_values + false_values):

Because of this, several official ROS 2 packages (such as nav2_msgs in the navigation2 stack) currently use True or False in their definitions, which compile fine in standard ROS 2 but break roslibrust's strict generation. This PR adds a .to_lowercase() call when matching "bool" in parse_ros_value.

Fixes

N/A

Checklist

  • Update CHANGELOG.md (I did not update this as this change does not seem notable enough to include 😅 let me know if I should do this anyway!)

Signed-off-by: Althea Tan <altheatan@google.com>
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.

1 participant