Skip to content

Inconsistence when modifying return object in ensure #3356

@crccw

Description

@crccw

Given code:

foo2 = 'dummy2'
result =  begin
    foo = 'dummy'
    foo
  ensure
    foo = foo2
  end
puts result, result.class

It works differently under MRI 2.2.1 and JRuby 9.0.1.0:

MRI 2.2.1:

dummy

JRuby 9.0.1.0:

dummy2

Most cases this won't be problem, but when you want to execute a block of code with a variable temporarily set to another values using the begin....ensure technique, you will get unwanted result. For example, tilt will not be able process erb files with JRuby due to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions