After checking the length of arr, emmylua will still report a need-check-nil warning when using arr[#arr]
Example
---@class Foo
---@field bar number
---@type Foo[]
local arr = {}
if #arr > 0 then
local v = arr[#arr].bar -- Warning: arr[#arr] may be nil
end