Added forced casting of int values to float for float-typed fields#216
Added forced casting of int values to float for float-typed fields#216EsipovPA wants to merge 1 commit intoros2:rollingfrom
Conversation
a77cf77 to
c1635b1
Compare
Signed-off-by: EsipovPA <esipov.p@mail.ru>
c1635b1 to
dafb769
Compare
clalancette
left a comment
There was a problem hiding this comment.
I have to say that personally, I'm not a fan. int and float are not the same thing, and thus I think any conversion like this should be up to the user to explicitly do. I'd like to hear opinions from @ros2/team, though.
|
Hello @clalancette! Thanks for the quick reply. It seems to me that this is a case of a widening conversion, that should be an option for these types of fields. In case of C++ code, the int values would be casted to float automatically, when passed to For example, instead of something like this or user should be able to write just and get the float value without raised exceptions. Still confused about the failed test though. Checking |
Yeah, I understand what you are trying to do. I still don't think it is a good idea, even if C++ allows it (there is nothing we can do about that, it is part of the language). |
|
At the minimum, the asserts should be converted to Python exceptions. I set one field of a with no stacktrace or what the actual type provided was. This took around 20 minutes to debug with gdb and some manual type checking. I do strongly believe that ints should be implicitly converted—I would argue that using |
Added casting int to floats for float-typed fields in messages
Added test for new feature
Closes this issue