I have some doubts about the outcome and the error messages caused by the following code examples:
(1)
Negative integer applied to a string:
"param1" : "value",
"param2" : ${param1}[-1]
Result:
Error: 'Invalid nested parameter format: ${param1}[-1] - The double quotes are missing!!!'!
Therefore with double quotes:
"param1" : "value",
"param2" : "${param1}[-1]"
Result:
{'param1': 'value', 'param2': 'e[-1]'}
(2)
The same with a list:
"testlist" : [1,2,3],
"value" : ${testlist}[-1]
Result:
Error: 'Invalid nested parameter format: ${testlist}[-1] - The double quotes are missing!!!'!
Therefore with double quotes:
"testlist" : [1,2,3],
"value" : "${testlist}[-1]"
Result:
{'testlist': [1, 2, 3], 'value': '3[-1]'}
(3)
Same with pair of empty square brackets:
"param1" : "value",
"param2" : ${param1}[]
Error: 'Invalid nested parameter format: ${param1}[] - The double quotes are missing!!!'!
"param1" : "value",
"param2" : "${param1}[]"
Error: 'The variable '${param1}[]' is not available!'!
"testlist" : [1,2,3],
"value" : ${testlist}[]
Error: 'Invalid nested parameter format: ${testlist}[] - The double quotes are missing!!!'!
"testlist" : [1,2,3],
"value" : "${testlist}[]"
Error: 'The variable '${testlist}[]' is not available!'!
In all cases above the square brackets are part of a dollar operator expression containing an existing parameter. Therefore the brackets have a syntactical meaning. Therefore strict syntax rules can be applied to them:
Negative integers are not allowed inside square brackets (would be a slicing issue). At least invalid mixed results like '3[-1]' must not occur.
A pair of square brackets must not be empty
I would assume now that it is possible to provide an error message like:
Expression '${testlist}[]' cannot be evaluated. Reason: Empty pair of square brackets detected.
This would be more helpful than simply telling that a variable does not exist.
I have some doubts about the outcome and the error messages caused by the following code examples:
(1) Negative integer applied to a string:
Result:
Error: 'Invalid nested parameter format: ${param1}[-1] - The double quotes are missing!!!'!
Therefore with double quotes:
Result:
{'param1': 'value', 'param2': 'e[-1]'}
(2) The same with a list:
Result:
Error: 'Invalid nested parameter format: ${testlist}[-1] - The double quotes are missing!!!'!
Therefore with double quotes:
Result:
{'testlist': [1, 2, 3], 'value': '3[-1]'}
(3) Same with pair of empty square brackets:
Error: 'Invalid nested parameter format: ${param1}[] - The double quotes are missing!!!'!
Error: 'The variable '${param1}[]' is not available!'!
Error: 'Invalid nested parameter format: ${testlist}[] - The double quotes are missing!!!'!
Error: 'The variable '${testlist}[]' is not available!'!
In all cases above the square brackets are part of a dollar operator expression containing an existing parameter. Therefore the brackets have a syntactical meaning. Therefore strict syntax rules can be applied to them:
'3[-1]'
must not occur.I would assume now that it is possible to provide an error message like:
Expression '${testlist}[]' cannot be evaluated. Reason: Empty pair of square brackets detected.
This would be more helpful than simply telling that a variable does not exist.