Your command isn't valid because it's missing a control character after 'bar', such as ';'. Bash rejects it as well:
$ bash -c "foo() { bar }" bash: -c: line 1: syntax error: unexpected end of file
Your command isn't valid because it's missing a control character after 'bar', such as ';'. Bash rejects it as well: