Failure to parse multiple (procs with do end blocks) as method arguments

This fails:

foo proc do

end, proc do

end

this works:

foo(proc do

end, proc do

end)

that it doesn’t work without parens suggests that there may be
ambiguity, but I don’t think there is, the second proc can not be an arg
to the first since it follows the block of the first, also this works
without parens:

foo proc {

}, proc {

}

why is there a difference?

Is there a bug here? If not, what’s the reason?

2012/11/1 Mean L. [email protected]:

foo proc do

end, proc do

end

foo proc do end is being interpreted as foo(proc) do end, so you get a
syntax error on the comma.

The curly { } block have higher priority when parsing, so foo proc { }
is interpreted as foo(proc { }) and the entire thing works.

– Matma R.

thanks, good to know about different binding precedence of do end and {}