From 5f9e047cf5d7f3adca4154b75cf8f68325330af8 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 26 Apr 2022 12:03:22 +0000 Subject: added test illustrating bug [27520c9b17] --- tests/error.test | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/error.test b/tests/error.test index af07ed7..08bd00c 100644 --- a/tests/error.test +++ b/tests/error.test @@ -351,6 +351,13 @@ test error-9.4 {try (ok, non-empty result) with on handler} { test error-9.5 {try (ok, non-empty result) with on ok handler} { try { list a b c } on ok {} { list d e f } } {d e f} +test error-9.6 {try (compilation of simple finaly token only, bug [27520c9b17])} -body { + set b {}; set l {} + try {lappend l error} finally [lappend l set b] + list $l $b +} -cleanup { + unset -nocomplain b l +} -result {{set b error} {}} # simple try tests - "on" handler matching -- cgit v0.12 From 2ce077e7c8a82332c62a598756f2de7dffb17376 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 26 Apr 2022 12:03:41 +0000 Subject: fixes compilation of try-command [27520c9b17]: compile only if finaly token is simple --- generic/tclCompCmdsSZ.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tclCompCmdsSZ.c b/generic/tclCompCmdsSZ.c index 53bff6e..abaf7a7 100644 --- a/generic/tclCompCmdsSZ.c +++ b/generic/tclCompCmdsSZ.c @@ -2929,6 +2929,9 @@ TclCompileTryCmd( goto failedToCompile; } finallyToken = TokenAfter(tokenPtr); + if (finallyToken->type != TCL_TOKEN_SIMPLE_WORD) { + goto failedToCompile; + } } else { goto failedToCompile; } -- cgit v0.12