Don`t assume default value for optional value type argument without default value #8754
+97
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the changes (Less than 80 chars)
Closes #6347 (in this specific format)
Background:
This issue appears to be a side effect of #5317 and/or #4354.
If an optional value type argument was not present in the input arguments, the InputParser was changed in 5317 to emit the default value for that type.
This was necessary to avoid compilation failures as
null
can not be converted to the value type.This PR removes this special handling from the InputParser and instead coalesces null arguments into the default value within the compiler itself.
This approach is very similar to how optional values are handled and allows the InputParser to correctly preserve an explicit null argument.
General note: This seems to only affects code-first types. For annotation-based types, we already have the correct nullability information, as an argument of type int? is in fact a Nullable whose default value is null.
Anyhow, for code-first types, this is not the case as f. e.
BooleanType
maps to the runtime-typebool
instead ofNullable<bool>
.