From 93ea2fcea92f79350067d684b29e520eff8eabe8 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sun, 12 Jan 2014 20:38:03 +1000 Subject: array: array set to non-dict should fail Currently returns the error message but does not set JIM_ERR Also add a test case Signed-off-by: Steve Bennett --- jim-array.c | 3 +++ tests/dict2.test | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/jim-array.c b/jim-array.c index 3bb74c6..bf07e07 100644 --- a/jim-array.c +++ b/jim-array.c @@ -174,6 +174,9 @@ static int array_cmd_set(Jim_Interp *interp, int argc, Jim_Obj *const *argv) /* Doesn't exist, so just set the list directly */ return Jim_SetVariable(interp, argv[0], listObj); } + else if (Jim_DictSize(interp, dictObj) < 0) { + return JIM_ERR; + } if (Jim_IsShared(dictObj)) { dictObj = Jim_DuplicateObj(interp, dictObj); diff --git a/tests/dict2.test b/tests/dict2.test index 01826dc..2e9bcd4 100644 --- a/tests/dict2.test +++ b/tests/dict2.test @@ -120,6 +120,10 @@ test dict-3.15 {compiled dict get error cleanliness - Bug 2431847} -body { } -returnCodes error -result {key "d" not known in dictionary} test dict-3.16 {dict/list shimmering - Bug 3004007} {set l [list p 1 p 2 q 3];dict get $l q;set l} {p 1 p 2 q 3} test dict-3.17 {dict/list shimmering - Bug 3004007} {set l [list p 1 p 2 q 3];dict get $l q;llength $l} 6 +test dict-3.18 {array set non-dict get command} -constraints jim -returnCodes error -body { + set a one + array set a {a b c d} +} -result {missing value to go with key} test dict-4.1 {dict replace command} { dict replace {a b c d} -- cgit v1.1