mod_mruby
mod_mruby copied to clipboard
begin/ensure variable scope incorrect?
if I execute the following code with mruby:
strX = 'some no foo'
begin
y='start'
puts y
foo
rescue => excp
strX = 'some foo error'
ensure
puts strX
puts 'end'
end
return
I get the output:
start some foo error end
Without the error line ( comment out 'foo') it's: start some no foo end
In mod_mruby the scope of a variable is not carried into the ensure:
strX = 'some no foo'
begin
y='start'
Apache.echo y
foo
rescue => excp
strX = 'some foo error'
ensure
Apache.echo strX
Apache.echo 'end'
end
return
Output from this is:
start
end
The variable seen by the ensure is set to nil (tested by getting an error if you attempt " strX += 'more text' " or some other manipulation of the nil value string). This could be intentional, but I wanted to be sure that this was working as designed or a problem.