aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tclcompat.tcl6
-rw-r--r--tests/misc.test6
2 files changed, 10 insertions, 2 deletions
diff --git a/tclcompat.tcl b/tclcompat.tcl
index 8669ed2..a1bc043 100644
--- a/tclcompat.tcl
+++ b/tclcompat.tcl
@@ -10,8 +10,10 @@ set env [env]
# Tcl 8.5 lassign
proc lassign {list args} {
- uplevel 1 [list foreach $args [concat $list {}] break]
- lrange $list [llength $args] end
+ # in case the list is empty...
+ lappend list {}
+ uplevel 1 [list foreach $args $list break]
+ lrange $list [llength $args] end-1
}
# case var ?in? pattern action ?pattern action ...?
diff --git a/tests/misc.test b/tests/misc.test
index e44106c..6bd9477 100644
--- a/tests/misc.test
+++ b/tests/misc.test
@@ -34,6 +34,12 @@ test regr-1.4 "format double percent" {
format (%d%%) 12
} {(12%)}
+test regr-1.5 "lassign with empty list" {
+ unset -nocomplain a b c
+ lassign {} a b c
+ info exists c
+} {1}
+
section "I/O Testing"
test io-1.1 "Read last line with no newline" {