irb
irb copied to clipboard
`chws` w/o argument does not change current workspace to main
The document (doc/irb/irb.rd.ja) says chws or irb_change_workspace command with no arguments changes the current workspace to the home workspace (i.e. the main object assigned to self when IRB begins). This does not happen in some cases.
Using irb 1.1.0.pre.2 with MRI master (d806078237).
The following example illustrates the problem -- the second invocation of chws, without an argument, is expected to change the workspace back to main. Actually, the workspace is not changed.
irb(main):001:0> chws Object.new
=> #<Object:0x000055c15c4919e8>
irb(#<Object:0x000055c15c4919e8>):002:0> chws
=> #<Object:0x000055c15c4919e8>
irb(#<Object:0x000055c15c4919e8>):003:0>
The cause of the problem seems to be IRB::Context#change_workspace at lib/irb/ext/change-ws.rb#L32, which saves the @home_workspace (via #home_workspace) only when it is first called without arguments, while it should do so before changing the workspace.