Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected ensure after eval. #1949

Closed
take-cheeze opened this issue Mar 26, 2014 · 4 comments
Closed

Unexpected ensure after eval. #1949

take-cheeze opened this issue Mar 26, 2014 · 4 comments

Comments

@take-cheeze
Copy link
Contributor

When running the following code:

a = []
begin
    a.push 0
    Kernel.eval 'p "test"'
    p a
ensure
    a = nil
end

It outputs following on mruby:

"test"
nil

Although it was expected to output:

"test"
[0]
@bjorndm
Copy link

bjorndm commented Mar 26, 2014

Actually, I'd expect a to be nil for this code. Ensure is always executed, and the a modified the one from outside the begin block. Or am I mistaken?

@mattn
Copy link
Contributor

mattn commented Mar 26, 2014

@bjorndm Look below's code

a = []
begin
    a.push 0
    puts "PASS1"
    Kernel.eval 'p "test"'
    puts "PASS2"
    p a
    puts "PASS3"
ensure
    puts "PASS4"
    a = nil
    puts "PASS5"
end
$ ruby ensure.rb
PASS1
"test"
PASS2
[0]
PASS3
PASS4
PASS5
$ mruby ensure.rb
PASS1
"test"
PASS4
PASS5
PASS2
nil
PASS3

@matz matz closed this as completed in 28871b9 Mar 26, 2014
matz added a commit that referenced this issue Mar 26, 2014
@take-cheeze
Copy link
Contributor Author

@matz Thank you for the quick fix!

@bjorndm
Copy link

bjorndm commented Mar 26, 2014

@mattn

OIC, thanks for giving me that example!

ghost pushed a commit to iij/mruby that referenced this issue Mar 31, 2014
ghost pushed a commit to iij/mruby that referenced this issue Mar 31, 2014
takeru added a commit to takeru/mruby that referenced this issue May 4, 2014
matz added a commit that referenced this issue May 4, 2014
ghost pushed a commit to iij/mruby that referenced this issue May 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants