Fixes #1438. Hmmm interesting typo not putting lex_state into endfn