Maybe it is not a bug, but I don't see a reason why the following code should not output 2.0. Tested in gnuplot 5.2.8.
gnuplot> a="1"
gnuplot> print sum [i = 1:2] a
warning: encountered a string when expecting a number
Did you try to generate a file name using dummy variable x or y?
The error message seems clear enough. "sum" wants numerical values to sum, not strings.
Compare
print sum [i=1:2] int(a)
or
print sum [i=1:2] real(a)
Yes, I understand the error. My concern is because the following two options work.
I am not used to gnuplot developer ideas, but I would expect
sumto support strings which contain numbers.