While refactoring some code in studio, I came across the following bug in the attached code:
function Profile._GetProfile(User)
local self
if typeof(User) == "Instance" then
self = PlayerProfileCache[User]
if not self then
self = setmetatable({}, Profile)
PlayerProfileCache[User] = self
end
return
else
error("Undefined behavior.")
end
return self
end
The warning is pointing to the line containing return self
. As you can clearly see, the line can indeed be reached if the User
argument is not an Instance.