fix #8978, inlining bug with closures

thanks @vtjnash for the reduced test case