----------------------------------------
> Date: Wed=2C 3 Nov 2010 11:35:03 +0900
> From: justincollins / ucla.edu
> Subject: Re: Strange whitespace parsing behavior on Ruby 1.8.7 (patchleve=
l 249/302)
> To: ruby-talk / ruby-lang.org
>
> Ehsanul Hoque wrote:
> >
> >>>>> An issue pops up when I use a method's integer return value in a fu=
nction argument while performing arithmetic on that value. Then missing whi=
tespace 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 want to rush to judgement and call this a bug=2C but it certainly se=
ems like one=2C hidden till now because you have have formatting that's sli=
ghtly ugly for the error to turn up. Here's an irb session that demonstrate=
s the issue:
> >>>>> irb(main):062:0* x =3D '123456'=3D> "123456"irb(main):063:0> x.slic=
e(1=2C x.size -2)SyntaxError: compile error(irb):63: syntax error=2C unexpe=
cted ')'=2C expecting kDO_BLOCK from (irb):63 from :0irb(main):064:0> x.sli=
ce(1=2C x.size - 2)=3D> "2345"irb(main):065:0> xslice(1=2C x.size-2)=3D> "2=
345"irb(main):066:0> x.slice(1=2C x.size -2)SyntaxError: compile error(irb)=
:66: syntax error=2C unexpected ')'=2C expecting kDO_BLOCK from (irb):66 fr=
om :0irb(main):067:0> x[x.size -3=2C1]ArgumentError: wrong number of argume=
nts (2 for 0) from (irb):67:in `size' from (irb):67 from :0irb(main):068:0>=
 x[x.size - 3=2C1]=3D> "4"irb(main):069:0> def ok(a=2Cb)irb(main):070:1> en=
d=3D> nilirb(main):071:0> ok(x.size +3=2C4)ArgumentError: wrong number of a=
rguments (2 for 0) from (irb):71:in `size' from (irb):71 from :0irb(main):0=
72: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):074:0> ok(4=2Cx.size + 3)=3D> nil
> >>
> >>>> Can you repost with proper indentation and line wrapping? Guessing
> >>>> from your text I assume you might have fallen into a unary / binary
> >>>> operator ambiguity.
> >>>>
> >>> Sorry about that=2C Hotmail's "rich text" formatting messed it up I b=
elieve Here it goes again with plain text:
> >>> irb(main):062:0* x =3D '123456'=3D> "123456"irb(main):063:0> x.slice(=
1=2C xsize -2)SyntaxError: compile error(irb):63: syntax error=2C unexpecte=
d ')'=2C expecting kDO_BLOCK from (irb):63 from :0 irb(main):064:0> x.slice=
(1=2C x.size - 2)=3D> "2345"irb(main):065:0> x.slice(1=2C x.size-2)=3D> "23=
45"irb(main):066:0> x.slice(1=2C x.size -2)SyntaxError: compile error(irb):=
66: syntax error=2C unexpected ')'=2C expecting kDO_BLOCK from (irb):66 fro=
m :0 irb(main):067:0> x[x.size -3=2C1]ArgumentError: wrong number of argume=
nts (2 for 0) from (irb):67:in `size' from (irb):67 from :0 irb(main):068:0=
> x[x.size - 3=2C1]=3D> "4"irb(main):069:0> def ok(a=2Cb)irb(main):070:1> e=
nd=3D> nilirb(main):071:0> ok(x.size +3=2C4)ArgumentError: wrong number of =
arguments (2 for 0) from (irb):71:in `size' from (irb):71 from :0 irb(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 :0 irb(main):074:0> ok(4=2Cx.size + 3)=3D> nil
> >>
> >>> Insert mode
> >>>
> >> Not really... :)
> >>
> >> robert
> >>
> > You know what=2C I should probably just use pastie. Here you go: http:/=
/pastie.org/1267606
> >
> >
> >
> > Insert mode
> >
>
> Robert was right.
>
> ok(x.size +3=2C4)
>
>
> is parsed as
>
>
> ok(x.size(+3=2C 4))
>
>
> while you seem to be expecting
>
>
> ok((x.size + 3)=2C 4))
>
>
> Similarly with all your other examples.
>
> -Justin


That makes sense. But the inconsistency between the different behaviors giv=
en just a small difference in whitespace is still quite off-putting.

Also how is this line parsed?:

x.slice(1=2C x.size -2)=A0

- It seems unreasonable to parse it any way other than that intended.Insert=
 mode 		 	   		  =