Skip to content

Ignore key bindings to methods inherited from Object - #928

Open
taekop wants to merge 1 commit into
ruby:masterfrom
taekop:fix-unknown-function-binding
Open

taekop wants to merge 1 commit into
ruby:masterfrom
taekop:fix-unknown-function-binding

Conversation

@taekop

@taekop taekop commented Oct 6, 2026

Copy link
Copy Markdown

Fixes #819

Control-d: exit in inputrc makes wrap_method_call find Kernel#exit through respond_to?(method_symbol, true) and call it with the key string, which raises TypeError and kills the session. Other Object/Kernel methods (abort, sleep, p, raise, ...) are reachable the same way.

This is the small workaround mentioned in the issue: wrap_method_call now skips methods whose owner is Object or one of its ancestors, so such a binding is ignored like any unknown function name. Methods defined on Reline::LineEditor (or a singleton alias, as in test_alias) still dispatch as before.

Not covered: internal LineEditor methods such as initialize or move_history can still be bound; that needs the explicit function registry discussed in the issue.

Testing

  • Added test_ignore_method_inherited_from_object to test/reline/test_macro.rb; it fails on master with TypeError and passes with this change.
  • bundle exec rake test: 409 tests, 0 failures, 0 errors (23 omissions).
  • Manual check on macOS with INPUTRC containing Control-d: exit: master crashes with TypeError on Ctrl-D, with this change the key is ignored and input continues.
  • IRB master test suite run against this branch of reline: 410 tests, 0 failures, 0 errors (3 omissions).

Binding a key to a function name such as `exit` in inputrc called
Kernel#exit with the key string and raised TypeError.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

Binding to exit command causes TypeError

1 participant