Skip to content

Avoid overflow exceptions when converting BOOL to bool#645

Merged
AArnott merged 1 commit into
mainfrom
fix624
Aug 9, 2022
Merged

Avoid overflow exceptions when converting BOOL to bool#645
AArnott merged 1 commit into
mainfrom
fix624

Conversation

@AArnott

@AArnott AArnott commented Aug 9, 2022

Copy link
Copy Markdown
Member

This means it has to be a lossy conversion, since BOOL is 4 bytes and bool is 1 byte. Generally .NET recommends avoiding lossy implicity operators (though explicit is ok). But for a type like this, it seems like super-high value for folks to be able to author if (!SomeBOOL()) and have that work without casts.

Fixes #624

@elachlan

elachlan commented Aug 9, 2022

Copy link
Copy Markdown
Contributor

The Tests which directly compare string values are failing. Those templates will need to be updated.

  • TestSimpleDelegate
  • TestMethodWithOverloads
  • TestSimpleStructure

This means it has to be a lossy conversion, since `BOOL` is 4 bytes and `bool` is 1 byte. Generally .NET recommends avoiding lossy implicity operators (though explicit is ok). But for a type like this, it seems like super-high value for folks to be able to author `if (!SomeBOOL())` and have that work without casts.

Fixes #624
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.

BOOL/BOOLEAN templates are incorrect

2 participants