The "problem" is caused by the shell option extglob.
extglob: on
[STEP 100] # echo $BASH_VERSION
4.4.12(1)-release
[STEP 101] # shopt -s extglob
[STEP 102] # echo @()
@()
[STEP 103] # function @() { shopt extglob; }
[STEP 104] # @()
extglob on
[STEP 105] # unset -f @()
[STEP 106] #
When extglob on, I guess Bash's syntax parser would treat @() as a whole (because it looks like a valid extended glob pattern) and pass it to the function command as one single paramter so function @() {} is in the function NAME {} syntax and so @() is the function name.
extglob: off
[STEP 107] # shopt -u extglob
[STEP 108] # echo @()
bash: syntax error near unexpected token `('
[STEP 109] # function @() { shopt extglob; }
[STEP 110] # @
extglob off
[STEP 111] #
When extglob off, function @() {} is in the function NAME() {} syntax and so @ is the function name.
Chet's explanation in the bug-bash mailing list:
A shell function name is a WORD, though POSIX mode restricts it to a NAME.
It does not undergo any expansions.
When extglob is enabled, @() is part of a WORD, since it's a valid extended
glob pattern, and glob patterns can be contained in a WORD. This is one
example of the differing parser behavior when extglob is enabled. So
there's no problem with defining a function named @(). When extglob is
not enabled, @() is not a valid pattern, and the parens are parsed as
separate operators. In this case they happen to make sense, and define a
function named @.
When you try to execute it, since it's not quoted, it undergoes the normal
word expansions, one of which is filename generation. It doesn't match
anything, so it's left intact, and the function named @() executes. When
nullglob is enabled, the pattern still doesn't match anything, and is
removed. This leaves you with the null command, which also executes, and
returns a status of 0.