Error: undefined local variable or method `formula' for Homebrew:Module

I’ve been running on macOS Catalina 10.15.4 for a while, but recently switched my default shell (and some associated config, dotfiles) from bash to zsh, and some Homebrew functionality now appears to be broken.

When running brew info socat (or any formula which does exist) I get the following error:

$ brew info socat
Error: undefined local variable or method `formula' for Homebrew:Module
Please report this issue:
  https://docs.brew.sh/Troubleshooting
/usr/local/Homebrew/Library/Homebrew/cmd/info.rb:112:in `block in print_info'
/usr/local/Homebrew/Library/Homebrew/cmd/info.rb:105:in `each'
/usr/local/Homebrew/Library/Homebrew/cmd/info.rb:105:in `each_with_index'
/usr/local/Homebrew/Library/Homebrew/cmd/info.rb:105:in `print_info'
/usr/local/Homebrew/Library/Homebrew/cmd/info.rb:92:in `info'
/usr/local/Homebrew/Library/Homebrew/brew.rb:110:in `<main>'

However, much other functionality, like brew search and brew upgrade work just fine.

brew doctor only reports a few “unexpected” headers/dylibs from one library I’ve installed manuallyy, no other Homebrew config issues.

Is there something obvious missing/misconfigured here?

Actually a bug in Homebrew, tracking in https://github.com/Homebrew/brew/issues/7639 and a fix is pending in https://github.com/Homebrew/brew/pull/7640