lexer: fix a bug in error handling code