diff --git a/src/compiler/codegen/events.js b/src/compiler/codegen/events.js
index 44657e38..fc817c03 100644
--- a/src/compiler/codegen/events.js
+++ b/src/compiler/codegen/events.js
@@ -1,6 +1,6 @@
/* @flow */
-const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/
+const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/
const fnInvokeRE = /\([^)]*?\);*$/
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/
diff --git a/test/unit/modules/compiler/codegen.spec.js b/test/unit/modules/compiler/codegen.spec.js
index e946e218..10c65618 100644
--- a/test/unit/modules/compiler/codegen.spec.js
+++ b/test/unit/modules/compiler/codegen.spec.js
@@ -345,6 +345,11 @@ describe('codegen', () => {
``,
`with(this){return _c('input',{on:{"input":function($event){onInput(');[\\'());');}}})}`
)
+ // function name including a `function` part (#9920)
+ assertCodegen(
+ '',
+ `with(this){return _c('input',{on:{"input":function($event){return functionName()}}})}`
+ )
})
it('generate events with multiple statements', () => {