From 52bd38f3bd89bbb4404183f768a17ccb38c50b47 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Sun, 4 Jan 2015 13:10:46 -0800 Subject: [PATCH] Don't double report lexer errors. --- src/wren_compiler.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wren_compiler.c b/src/wren_compiler.c index 58ab3033..92a7e5c9 100644 --- a/src/wren_compiler.c +++ b/src/wren_compiler.c @@ -291,6 +291,11 @@ static void error(Compiler* compiler, const char* format, ...) compiler->parser->hasError = true; Token* token = &compiler->parser->previous; + + // If the parse error was caused by an error token, the lexer has already + // reported it. + if (token->type == TOKEN_ERROR) return; + fprintf(stderr, "[%s line %d] Error on ", compiler->parser->sourcePath->value, token->line);