From 8dcba4c58ce0027634e5a0569e07e41352b5aefd Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 24 Feb 2025 12:56:22 +0000 Subject: avoid "can't read "::tcltestlib": no such variable" in tests *io-60.1 if load catches a fail for some reason --- tests/chanio.test | 1 + tests/io.test | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/chanio.test b/tests/chanio.test index fb566d4..54c566f 100644 --- a/tests/chanio.test +++ b/tests/chanio.test @@ -29,6 +29,7 @@ namespace eval ::tcl::test::io { variable msg variable expected + set ::tcltestlib {} catch { ::tcltest::loadTestedCommands package require -exact Tcltest [info patchlevel] diff --git a/tests/io.test b/tests/io.test index 1e17c43..adffd89 100644 --- a/tests/io.test +++ b/tests/io.test @@ -29,6 +29,7 @@ namespace eval ::tcl::test::io { variable msg variable expected + set ::tcltestlib {} catch { ::tcltest::loadTestedCommands package require -exact Tcltest [info patchlevel] -- cgit v0.12 From 4b19e5ab3643a8c80bd57b57293ef5d54bda0446 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Feb 2025 17:52:46 +0000 Subject: Fix [211ac77119]: return manual page has a no longer valid example --- doc/return.n | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/doc/return.n b/doc/return.n index ea590ea..3ef2a36 100644 --- a/doc/return.n +++ b/doc/return.n @@ -13,11 +13,11 @@ .SH NAME return \- Return from a procedure, or set return code of a script .SH SYNOPSIS +.nf \fBreturn \fR?\fIresult\fR? -.sp \fBreturn \fR?\fB\-code \fIcode\fR? ?\fIresult\fR? -.sp \fBreturn \fR?\fIoption value \fR...? ?\fIresult\fR? +.fi .BE .SH DESCRIPTION .PP @@ -54,7 +54,7 @@ of the procedure is 0 (\fBTCL_OK\fR). . Error return: the return code of the procedure is 1 (\fBTCL_ERROR\fR). The procedure command behaves in its calling context as if it -were the command \fBerror\fR \fIresult\fR. See below for additional +were the command \fBerror\fI result\fR. See below for additional options. .TP 13 \fBreturn\fR (or \fB2\fR) @@ -105,6 +105,7 @@ script. As documented above, the \fB\-code\fR entry in the return options dictionary receives special treatment by Tcl. There are other return options also recognized and treated specially by Tcl. They are: +.\" OPTION: -errorcode .TP \fB\-errorcode \fIlist\fR . @@ -117,6 +118,7 @@ the \fB\-code error\fR option is provided, Tcl will set the value of the \fB\-errorcode\fR entry in the return options dictionary to the default value of \fBNONE\fR. The \fB\-errorcode\fR return option will also be stored in the global variable \fBerrorCode\fR. +.\" OPTION: -errorinfo .TP \fB\-errorinfo \fIinfo\fR . @@ -135,12 +137,15 @@ the procedure. Typically the \fIinfo\fR value is supplied from the value of \fB\-errorinfo\fR in a return options dictionary captured by the \fBcatch\fR command (or from the copy of that information stored in the global variable \fBerrorInfo\fR). +.\" OPTION: -errorstack .TP \fB\-errorstack \fIlist\fR +. .VS 8.6 The \fB\-errorstack\fR option receives special treatment only when the value of the \fB\-code\fR option is \fBTCL_ERROR\fR. Then \fIlist\fR is the initial -error stack, recording actual argument values passed to each proc level. The error stack will +error stack, recording actual argument values passed to each proc level. +The error stack will also be reachable through \fBinfo errorstack\fR. If no \fB\-errorstack\fR option is provided to \fBreturn\fR when the \fB\-code error\fR option is provided, Tcl will provide its own @@ -153,6 +158,7 @@ the value of \fB\-errorstack\fR in a return options dictionary captured by the \fBcatch\fR command (or from the copy of that information from \fBinfo errorstack\fR). .VE 8.6 +.\" OPTION: -level .TP \fB\-level \fIlevel\fR . @@ -165,6 +171,7 @@ be \fIcode\fR. If no \fB\-level\fR option is provided, the default value of \fIlevel\fR is 1, so that \fBreturn\fR sets the return code that the current procedure returns to its caller, 1 level up the call stack. The mechanism by which these options work is described in more detail below. +.\" OPTION: -options .TP \fB\-options \fIoptions\fR . @@ -257,16 +264,8 @@ proc factorial {n} { if {$n < 2} { \fBreturn\fR 1 } - set m [expr {$n - 1}] - set code [catch {factorial $m} factor] - if {$code != 0} { - \fBreturn\fR -code $code $factor - } + set factor [factorial [expr {$n - 1}]] set product [expr {$n * $factor}] - if {$product < 0} { - \fBreturn\fR -code error \e - "overflow computing factorial of $n" - } \fBreturn\fR $product } .CE -- cgit v0.12