Fix breakage caused by early function loading

Fixes #17955
Merge pull request #17961 from cachedout/issue_17955

Fix breakage caused by early function loading