case when return nil ? #675

Closed
mattn opened this Issue Dec 27, 2012 · 1 comment

3 participants

@mattn
def fb
  n = 0
  Proc.new do
    n += 1
    case
    when n % 15 == 0 then "FizzBuzz"
    when n % 3 == 0 then "Fizz"
    when n % 5 == 0 then "Buzz"
    else n
    end
  end
end

p fb.call
=> nil
@matz matz closed this in 9d56acb Dec 28, 2012
@skandhas

I think the patch that does not solve the problem, in other words, it have another problem in generating NODE_CASE.

example:

def fb
  n = 0
  Proc.new do
    n += 1
    case n    # head
    when n % 5 == 0 then "Buzz"
    else n
    end
  end
end

p fb.call

ruby 1.9.x output: 1
mruby output : "Buzz"

Another:

def fb
  n = 0
  Proc.new do
    n += 1
    case n   # head
    when n % 15 == 0 then "FizzBuzz"
    when n % 3 == 0 then "Fizz"
    when n % 5 == 0 then "Buzz"
    else n
    end
  end
end

p fb.call

ruby 1.9.x output: 1
mruby crashed. Segmentation fault

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment