Closed HolQue closed 4 months ago
Hi Son,
(1) is as expected, because we let the data-type of the $-expression as it is. => speaking error message required if the data-type is wrong. (2) should have the result of (1). Reason: If we set double quotes around the $-expression, then we convert the value to string (not composite types). (3) behaviour of (1) and corrected (2) expected.
Thank you, Thomas
Hello Holger, Hello Thomas,
I pushed new commit b4fc78df46d to stabi branch to fix the issue mentioned in this ticket.
Thank you, Son
Hi Son,
val03
and val09
do not work:
"intparam" : 0,
"stringparam" : "A",
"listparam" : ["A", "B"],
"dictparam" : {"0" : 0, "A" : 1, "B" : 2},
//
"val01" : ${listparam}[${intparam}],
"val02" : ${listparam}[1],
// "val03" : ${dictparam}['${intparam}'], // Error: 'The variable '${dictparam}['${intparam}']' is not available!'!
"val04" : ${dictparam}[${stringparam}],
"val05" : ${dictparam}['${stringparam}'],
"val06" : ${dictparam}['A'],
//
"val07" : "${listparam}[${intparam}]",
"val08" : "${listparam}[1]",
// "val09" : "${dictparam}['${intparam}']", // Error: 'The variable '${dictparam}['${intparam}']' is not available!'!
"val10" : "${dictparam}[${stringparam}]",
"val11" : "${dictparam}['${stringparam}']",
"val12" : "${dictparam}['A']"
Hello Holger,
I pushed the commit 572c5f91dce65 to the stabi branch to fix the issue related to val03
and val09
as you mentioned above.
Thank you, Son
Hello Holger,
I pushed new commit 64ca06a73e to the stabi branch to fix the issue in test cases JPP_0513
Thank you, Son
Retest successful. Issue can be closed.
Merged to develop branch
solved with version 0.10.0
JSON code
(1) Access to elements with hard coded key name (encapsulated in single quotes) and key name as parameter (without single quotes) on the right hand side of the colon:
Outcome:
tmp1
andtmp2
with value"A"
. OK, so far.(2) With single quotes around parameter:
"tmp3" : ${testdict}['${key1}']
Result:
Error: 'The variable '${testdict}['${key1}']' is not available!'!
Hmm. I can live with that. But nevertheless, my feeling is that this should not be an error. Why not a little bit more robust? We speak about a dictionary key. This is expected to be of type string. The single quotes inside the square brackets indicate that the content shall be interpreted as string. The parameter
key1
, used as dictionary key, is already of type string. So what is the problem here? All things are completely fine already. The single quotes are irrelevant in this case and really should not harm the computation. And telling that the entire expression (variable)'${testdict}['${key1}']'
does not exist, is in my opinion also not helpful - or not precise enough. Because this error message does not really tell, what exactly the problem is.(3) The same on the left hand side of the colon. Here it is completely other way round.
Without quotes => error
${testdict}[${key1}] : "C"
Error: 'Could not set variable 'testdict[keyA]' with value 'C'! Reason: name 'keyA' is not defined'!
With quotes => success
${testdict}['${key1}'] : "D"
Why are the single quotes a problem on the right hand side of the colon and required at the left hand side of the colon?
This overall is so much confusing and I really have problems to explain that in the documentation. I urgently ask to rework the syntax.