luau: metatable refinement breaks when nullable fields are present in the metatable part

type A = setmetatable<{}, {test: DateTime?}>;
local x: A = setmetatable({}, {
	
	test = nil,
})

even if you set test to DateTime.now(), it still errors:
RobloxStudioBeta_kBC00D3FQp

new type solver

2 Likes

Thanks for the report! The issue here is that bidirectional typing, which is the piece of type inference that pushes expected types (like the A you’ve annotated on x here) into setmetatable’s metatable type. We’ll look into fixing this!

2 Likes

Sorry for the delay in circling back, but a fix for this problem in the latest release and it should be rolling out today. Thanks again for the report!

1 Like