From f1134cc5f18aef555e3c8573d0fa62b17f3908a0 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Mon, 20 Feb 2023 20:42:09 -0500 Subject: [PATCH] ca65 improve error for unclosed scopes See: #1779 --- src/ca65/symtab.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ca65/symtab.c b/src/ca65/symtab.c index afe7b3ad6..a01d14bd8 100644 --- a/src/ca65/symtab.c +++ b/src/ca65/symtab.c @@ -570,7 +570,18 @@ void SymCheck (void) /* Check for open scopes */ if (CurrentScope->Parent != 0) { - Error ("Local scope was not closed"); + if (CurrentScope->Label) { + /* proc has a label indicating the line it was opened. */ + LIError (&CurrentScope->Label->DefLines, + "Local proc '%s' was not closed", + GetString (CurrentScope->Name)); + } else { + /* scope has no label to track a line number, uses end-of-document line instead. + ** Anonymous scopes will reveal their internal automatic name. + */ + Error ("Local scope '%s' was not closed", + GetString (CurrentScope->Name)); + } } /* First pass: Walk through all symbols, checking for undefined's and