From 5ab653feb0f92621dfa72b70722477353ae22c75 Mon Sep 17 00:00:00 2001 From: dkf Date: Wed, 15 Feb 2012 09:51:12 +0000 Subject: * generic/tclCompCmds.c (TclCompileDictForCmd): [Bug 3487626]: Fix crash in compilation of [dict for] when its implementation command is used directly rather than through the ensemble. --- ChangeLog | 16 +++++++++++----- generic/tclCompCmds.c | 3 ++- tests/dict.test | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b79e92a..94dc4ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,18 @@ +2012-02-15 Donal K. Fellows + + * generic/tclCompCmds.c (TclCompileDictForCmd): [Bug 3487626]: Fix + crash in compilation of [dict for] when its implementation command is + used directly rather than through the ensemble. + 2012-02-09 Don Porter - * generic/tclStringObj.c: [Bug 3484402] Correct Off-By-One + * generic/tclStringObj.c: [Bug 3484402]: Correct Off-By-One error appending unicode. Thanks to Poor Yorick. Also corrected test - for when growth is needed. + for when growth is needed. 2012-02-06 Don Porter - * generic/tclCompCmds.c: [Bug 3485022] TclCompileEnsemble() avoid + * generic/tclCompCmds.c: [Bug 3485022]: TclCompileEnsemble() avoid * tests/trace.test: compile when exec traces set. 2012-02-06 Miguel Sofer @@ -14,10 +20,10 @@ * generic/tclTrace.c: Fix for [Bug 3484621]: insure that * tests/trace.test: execution traces on bytecoded commands bump the interp's compile epoch. - + 2012-02-02 Jan Nijtmans - * generic/tclUniData.c: [Frq 3464401] Support Unicode 6.1 + * generic/tclUniData.c: [FRQ 3464401]: Support Unicode 6.1 * generic/regc_locale.c: 2012-02-02 Don Porter diff --git a/generic/tclCompCmds.c b/generic/tclCompCmds.c index 1f8bd21..9eb74f5 100644 --- a/generic/tclCompCmds.c +++ b/generic/tclCompCmds.c @@ -972,7 +972,7 @@ TclCompileDictForCmd( * Compile the loop body itself. It should be stack-neutral. */ - SetLineInformation (4); + SetLineInformation(3); CompileBody(envPtr, bodyTokenPtr, interp); TclEmitOpcode( INST_POP, envPtr); @@ -1172,6 +1172,7 @@ TclCompileDictUpdateCmd( TclEmitInstInt4( INST_BEGIN_CATCH4, range, envPtr); ExceptionRangeStarts(envPtr, range); + SetLineInformation(parsePtr->numWords - 1); CompileBody(envPtr, bodyTokenPtr, interp); ExceptionRangeEnds(envPtr, range); diff --git a/tests/dict.test b/tests/dict.test index 5821c32..b92893e 100644 --- a/tests/dict.test +++ b/tests/dict.test @@ -1194,6 +1194,57 @@ test dict-22.11 {dict with command: no recursive structures [Bug 1786481]} { string range [append foo OK] end-1 end } OK +proc linenumber {} { + dict get [info frame -1] line +} +test dict-23.1 {dict compilation crash: Bug 3487626} { + apply {n { + set e {} + set k {} + dict for {a b} {c {d {e {f g}}}} { + ::tcl::dict::for {h i} $b { + dict update i e j { + ::tcl::dict::update j f k { + return [expr {$n - [linenumber]}] + } + } + } + } + }} [linenumber] +} 5 +test dict-23.2 {dict compilation crash: Bug 3487626} knownBug { + # Something isn't quite right in line number and continuation line + # tracking; at time of writing, this test produces 7, not 5, which + # indicates that the extra newlines in the non-script argument are + # confusing things. + apply {n { + set e {} + set k {} + dict for {a { +b +}} {c {d {e {f g}}}} { + ::tcl::dict::for {h { +i +}} ${ +b +} { + dict update { +i +} e { +j +} { + ::tcl::dict::update { +j +} f k { + return [expr {$n - [linenumber]}] + } + } + } + } + }} [linenumber] +} 5 +rename linenumber {} + # cleanup ::tcltest::cleanupTests return -- cgit v0.12