From: Ruby Info Date: 2011-08-24T12:39:32+09:00 Subject: Re: Possble bug in Ruby parser (Fixnum#times within "case" statement) So this refactoring works: def kk while ( case @state when :init 10.times do |index| puts "index = #{index}" end @state = :end true when :end puts "END" end ) end end @state = :init kk Which suggests the parser is confused about which to evaluate first, the while or the case block. But I don't think it's ambiguous, since the case/when must be evaluated first, since the when only goes with the case. I wonder if there's a 'case' to be made for a fix here. David On 08/22/2011 03:36 PM, IƱaki Baz Castillo wrote: > 2011/8/22 Ryan Davis: >>> It's much more complex than your code which cannot work in a real TCP >>> server in which nobody can expect to receive the entire protocol >>> message in a single TCP package. >> >> There is nothing in my code __example__ that implies that you receive the entire payload. You're inferring that on your own. The complexity you introduce at the level you do it at is unnecessary. > > Your code calls get_body() after the function parse_headers(), in any case: > > def receive_data(data) > @buffer<< data > @parser.reset > @parser_nbytes = 0 > parse_headers > get_body > process_request > end > > Why should you call get_body() when maybe parse_header() method has > not finished receiving all the headers? >