summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2017-10-24 11:25:29 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2017-10-24 11:25:29 (GMT)
commit634213a9c8c174ea37ebf90660b21b4469e13c57 (patch)
tree328e5529b92e05e51bec3cf390af2925955393c2
parent47a07276958baa54a3f95b350eb941adfdc7e9d4 (diff)
parent8e537759cf8215fe82bd51ca374f580d8b2c4a99 (diff)
downloadtcl-634213a9c8c174ea37ebf90660b21b4469e13c57.zip
tcl-634213a9c8c174ea37ebf90660b21b4469e13c57.tar.gz
tcl-634213a9c8c174ea37ebf90660b21b4469e13c57.tar.bz2
[fc1409fc91] Method cloning needs to be careful with body representations.
-rw-r--r--generic/tclOOMethod.c1
-rw-r--r--tests/oo.test11
2 files changed, 12 insertions, 0 deletions
diff --git a/generic/tclOOMethod.c b/generic/tclOOMethod.c
index 9c49caa..e8fad82 100644
--- a/generic/tclOOMethod.c
+++ b/generic/tclOOMethod.c
@@ -1314,6 +1314,7 @@ CloneProcedureMethod(
*/
bodyObj = Tcl_DuplicateObj(pmPtr->procPtr->bodyPtr);
+ Tcl_GetString(bodyObj);
TclFreeIntRep(bodyObj);
/*
diff --git a/tests/oo.test b/tests/oo.test
index b538b60..2a6eb80 100644
--- a/tests/oo.test
+++ b/tests/oo.test
@@ -2048,6 +2048,17 @@ test oo-15.14 {OO: object cloning with target NS} -setup {
} -cleanup {
Cls destroy
} -result {{} ::dupens::test-15.14}
+test oo-15.15 {method cloning must ensure that there is a string representation of bodies} -setup {
+ oo::class create cls
+} -body {
+ cls create foo
+ oo::objdefine foo {
+ method m1 {} [string map {a b} {return hello}]
+ }
+ [oo::copy foo] m1
+} -cleanup {
+ cls destroy
+} -result hello
test oo-16.1 {OO: object introspection} -body {
info object