E
Ehsanul Hoque
An issue pops up when I use a method's integer return value in a function a=
rgument while performing arithmetic on that value. Then missing whitespace =
between the arithmetical operator and the second argument can cause random =
errors=2C but only if there is whitespace preceding the operator. I don't w=
ant to rush to judgement and call this a bug=2C but it certainly seems like=
one=2C hidden till now because you have have formatting that's slightly ug=
ly for the error to turn up. Here's an irb session that demonstrates the is=
sue:
irb(main):062:0* x =3D '123456'=3D> "123456"irb(main):063:0> x.slice(1=2C x=
size -2)SyntaxError: compile error(irb):63: syntax error=2C unexpected ')'=
=2C expecting kDO_BLOCK from (irb):63 from :0irb(main):064:0>=
x.slice(1=2C x.size - 2)=3D> "2345"irb(main):065:0> x.slice(1=2C x.size-2)=
=3D> "2345"irb(main):066:0> x.slice(1=2C x.size -2)SyntaxError: compile err=
or(irb):66: syntax error=2C unexpected ')'=2C expecting kDO_BLOCK fr=
om (irb):66 from :0irb(main):067:0> x[x.size -3=2C1]ArgumentError: w=
rong number of arguments (2 for 0) from (irb):67:in `size' fr=
om (irb):67 from :0irb(main):068:0> x[x.size - 3=2C1]=3D> "4"irb(mai=
n):069:0> def ok(a=2Cb)irb(main):070:1> end=3D> nilirb(main):071:0> ok(x.si=
ze +3=2C4)ArgumentError: wrong number of arguments (2 for 0) from (i=
rb):71:in `size' from (irb):71 from :0irb(main):072:0> ok(4=
=2Cx.size +3)SyntaxError: compile error(irb):72: syntax error=2C unexpected=
')'=2C expecting kDO_BLOCK from (irb):72 from :0irb(main):07=
4:0> ok(4=2Cx.size + 3)=3D> nil
=
rgument while performing arithmetic on that value. Then missing whitespace =
between the arithmetical operator and the second argument can cause random =
errors=2C but only if there is whitespace preceding the operator. I don't w=
ant to rush to judgement and call this a bug=2C but it certainly seems like=
one=2C hidden till now because you have have formatting that's slightly ug=
ly for the error to turn up. Here's an irb session that demonstrates the is=
sue:
irb(main):062:0* x =3D '123456'=3D> "123456"irb(main):063:0> x.slice(1=2C x=
size -2)SyntaxError: compile error(irb):63: syntax error=2C unexpected ')'=
=2C expecting kDO_BLOCK from (irb):63 from :0irb(main):064:0>=
x.slice(1=2C x.size - 2)=3D> "2345"irb(main):065:0> x.slice(1=2C x.size-2)=
=3D> "2345"irb(main):066:0> x.slice(1=2C x.size -2)SyntaxError: compile err=
or(irb):66: syntax error=2C unexpected ')'=2C expecting kDO_BLOCK fr=
om (irb):66 from :0irb(main):067:0> x[x.size -3=2C1]ArgumentError: w=
rong number of arguments (2 for 0) from (irb):67:in `size' fr=
om (irb):67 from :0irb(main):068:0> x[x.size - 3=2C1]=3D> "4"irb(mai=
n):069:0> def ok(a=2Cb)irb(main):070:1> end=3D> nilirb(main):071:0> ok(x.si=
ze +3=2C4)ArgumentError: wrong number of arguments (2 for 0) from (i=
rb):71:in `size' from (irb):71 from :0irb(main):072:0> ok(4=
=2Cx.size +3)SyntaxError: compile error(irb):72: syntax error=2C unexpected=
')'=2C expecting kDO_BLOCK from (irb):72 from :0irb(main):07=
4:0> ok(4=2Cx.size + 3)=3D> nil
=