Explicitly passing nil
does not set serialized value to nil
#7702
Labels
enhancement
New feature or surprising current feature
good first issue
Good for newcomers
runtime
Related to the sorbet-runtime gem
Input
→ View on sorbet.run
Observed output
When this runs, it shows
"x"
.Expected behavior
It should be possible to specify the default serialized value of an enum to
nil
. Sorbet believes this is possible statically, and says the type isNilClass
.But at runtime, the value printed is
"x"
, because sorbet-runtime does not distinguish between "explicitly passednil
for the serialized value" vs "passed no arguments."Ideally, we fix this in sorbet-runtime using something like a private constant:
and we check whether
serialized_value
isUNSET
instead of whether it's nil to determine whether to infer a string serialized value.The text was updated successfully, but these errors were encountered: