Do not resolve labels across function boundary

Fix #19331.
nit: could you document this method?