Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 10505 --- string function returns null on null parameter of type string. #10553

Merged
merged 3 commits into from
Nov 30, 2020

Conversation

KevinRansom
Copy link
Member

Fixes the issue: #10505 - string function returns null on null parameter of type string.

The error was introduced by an optimization in a recent PR. That for any type that was discoverable at compile time as a string, it just nop'd.

The fix evaluated the value for values typed as string, and if they are null, it returns a "". This restores the original behaviour that for string nulls it returns a "", although it goes through a ton less code now :-).


when 'T : string =
if value = unsafeDefault<'T> then ""
else (# "" value : string #) // force no-op
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is needed for these lines too (further down below)

             when 'T : StringBuilder = let x = (# "" value : StringBuilder #) in x.ToString()
             when 'T : IFormattable = let x = (# "" value : IFormattable #) in x.ToString(null, CultureInfo.InvariantCulture)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsyme good eyes, on it :-)

@KevinRansom KevinRansom deleted the issue10505 branch January 21, 2022 09:05
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.

None yet

4 participants