diff options
| author | dkf <donal.k.fellows@manchester.ac.uk> | 2016-03-27 16:37:11 (GMT) |
|---|---|---|
| committer | dkf <donal.k.fellows@manchester.ac.uk> | 2016-03-27 16:37:11 (GMT) |
| commit | 79e34ea63c86a40917630be738c7cf19da134ac7 (patch) | |
| tree | 2a979d92014a91288560d7d033fb722bb3e606b8 | |
| parent | 1014baa6f8b35c3d3068697f656ace7363e493a2 (diff) | |
| download | tcl-79e34ea63c86a40917630be738c7cf19da134ac7.zip tcl-79e34ea63c86a40917630be738c7cf19da134ac7.tar.gz tcl-79e34ea63c86a40917630be738c7cf19da134ac7.tar.bz2 | |
[47ac84309b] Fix problems with [lreplace] compilation.
| -rw-r--r-- | generic/tclCompCmdsGR.c | 14 | ||||
| -rw-r--r-- | tests/lreplace.test | 11 |
2 files changed, 23 insertions, 2 deletions
diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index 87ed745..9f430ea 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -1488,8 +1488,18 @@ TclCompileLreplaceCmd( return TCL_ERROR; } - if(idx2 != INDEX_END && idx2 >= 0 && idx2 < idx1) { - idx2 = idx1-1; + /* + * Compilation fails when one index is end-based but the other isn't. + * Fixing this will require more bytecodes, but this is a workaround for + * now. [Bug 47ac84309b] + */ + + if ((idx1 <= INDEX_END) != (idx2 <= INDEX_END)) { + return TCL_ERROR; + } + + if (idx2 != INDEX_END && idx2 >= 0 && idx2 < idx1) { + idx2 = idx1 - 1; } /* diff --git a/tests/lreplace.test b/tests/lreplace.test index e66a331..55a36a8 100644 --- a/tests/lreplace.test +++ b/tests/lreplace.test @@ -181,6 +181,17 @@ test lreplace-4.11 {lreplace end index first} { test lreplace-4.12 {lreplace end index first} { lreplace {0 1 2 3 4} end-2 2 a b c } {0 1 a b c 3 4} + +test lreplace-5.1 {compiled lreplace: Bug 47ac84309b} { + apply {x { + lreplace $x end 0 + }} {a b c} +} {a b c} +test lreplace-5.2 {compiled lreplace: Bug 47ac84309b} { + apply {x { + lreplace $x end 0 A + }} {a b c} +} {a b A c} # cleanup catch {unset foo} |
