It's either a bug or a misfeature of IRb. It is well-known that due to the pretty hackish way IRb is implemented, it does not behave correctly for all corner-cases.
The incompatibility probably everybody knows is that in Ruby, methods defined at the top-level become private
instance methods of Object
, whereas in IRb, they become public
instance methods of Object
. Another obvious behavioral difference is that in IRb, require_relative
doesn't work, because it searches relative to the current file, but in IRb, there is no current file.
There are also some differences in what syntax gets accepted, I believe, and something to do with local variables and when exactly they are and aren't defined.
So, it is not inconceivable that there might also be some behavioral differences wrt. Refinements. In fact, I myself have encountered that error message, and running the exact same code outside IRb, either with ruby -e
, from a file, or from a different REPL, always made it go away.