PLC-lang / rusty

Structured Text Parser and LLVM Frontend
GNU Lesser General Public License v3.0
181 stars 47 forks source link

feat: Be more lenient when dealing with integer values in conditions #1186

Closed volsa closed 1 month ago

volsa commented 1 month ago

Resolves https://github.com/PLC-lang/rusty/issues/1148

Previously, if and while statements expected the condition to be of type boolean and otherwise returned an error. Some projects make a lot of use of integer values as conditions, hence this PR distinguish between these two cases and returns a warning for the latter. Also values that evaluate to 0 or 1 are allowed without any warning / error.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 96.29630% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.62%. Comparing base (4a1f868) to head (f2c3b6e).

Files Patch % Lines
src/validation/statement.rs 96.29% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1186 +/- ## ========================================== - Coverage 95.62% 95.62% -0.01% ========================================== Files 150 150 Lines 42646 42655 +9 ========================================== + Hits 40779 40787 +8 - Misses 1867 1868 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.