From c51a26976c735531cf2f63d503f125da87f90133 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 18 May 2017 06:21:23 -0700 Subject: parser: bugfix: set line number on tokens. This issue was revealed as a garbage line number in an unbound variable warning diagnostic, where the variable occurs in a quasi word list literal. A small test case is (list #`@var`) where var unbound. The fix is, in the lexer, to set the yylval->lineno for all tokens which are declared as in the grammar file, for which doing so has beens neglected. We do this even for those tokens whose line number values are never accessd in any rule; it could arise in the future. * parser.l (grammar): Set the yylval->lineno for the tokens HASH_BACKSLASH, HASH_B_QUOTE, HASH_SLASH, WORDS, WSPLICE, QWORDS and QWSPLICE. --- parser.l | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/parser.l b/parser.l index fef31835..501f878c 100644 --- a/parser.l +++ b/parser.l @@ -619,16 +619,19 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} #\\ { yy_push_state(CHRLIT, yyscanner); + yylval->lineno = yyextra->lineno; return HASH_BACKSLASH; } #b' { yy_push_state(BUFLIT, yyscanner); + yylval->lineno = yyextra->lineno; return HASH_B_QUOTE; } #[/] { yy_push_state(REGEX, yyscanner); + yylval->lineno = yyextra->lineno; return HASH_SLASH; } @@ -639,21 +642,25 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} #\" { yy_push_state(WLIT, yyscanner); + yylval->lineno = yyextra->lineno; return WORDS; } #\*\" { yy_push_state(WLIT, yyscanner); + yylval->lineno = yyextra->lineno; return WSPLICE; } #\` { yy_push_state(QWLIT, yyscanner); + yylval->lineno = yyextra->lineno; return QWORDS; } #\*\` { yy_push_state(QWLIT, yyscanner); + yylval->lineno = yyextra->lineno; return QWSPLICE; } -- cgit v1.2.3