Open lake-effect opened 1 year ago
@paracycle, regarding your comment in https://github.com/sorbet/sorbet/issues/6621#issuecomment-1351577985:
I am surprised that Tapioca is generating a non-nilable column type here.
It seems like we're generating this as a non-type on purpose: https://github.com/Shopify/tapioca/blob/main/spec/tapioca/dsl/compilers/active_record_columns_spec.rb#L169-L212. If the code presented here makes sense, we should change the DSL compiler to produce a nilable type.
Referred from https://github.com/sorbet/sorbet/issues/6621
Input
Model:
Migration:
Annotation RBI (generated by
tapioca
):Observed output
Expected behavior
The check should have passed, because it is possible for
self.short_code
to be eithernil
or defined depending on howShortcode.create!
is called. You can callShortcode.create!(code: "my_code")
and create a record withcode
defined, and you can also callShortcode.create!
at which point line 7 above will assign a random code. The code is not unreachable.Sorbet version: 0.5.10160 Tapioca version: 0.10.3