Issue with Default(T) in Nullable Type

Issue #161 wontfix
Todd Flora created an issue

Hi Stefan,

We just recently upgraded to the 1.2 release of Spring4d and noticed that the nullable type was changed in spring.pas. The Clear method was removed and in the operator overload Default(T) was provided instead. This breaks null values and we can also see that you have already updated the tip of your code with changes to resolve this.

We are not in a position to upgrade to the tip of the source at this time but need to resolve this issue in our 1.2 code base. Can you suggest a patch for us. For instance can we just grab the nullable type from the spring unit and replace ours without other side effects?

Comments (7)

  1. Todd Flora reporter

    OK so we just added back the Clear method to Nullable and are calling it in the operator overload for Variant. Seems to work.

  2. Stefan Glienke repo owner

    The point of removing the Clear method was to avoid the issue that you might call Clear on a nullable property which would result in clearing the value copy that was returned by the property getter but not changing the underlying value. In short: to make Nullable<T> immutable.

    If you want to clear a nullable then assign Null or Nullable.Null to it.

  3. Todd Flora reporter

    Yes correct, So I see there was an issue that you fixed this morning. I will apply this change to our code.

    Capture.JPG

    Thanks,

  4. Log in to comment