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

Gracefully handle incorrect command aliases #1059

Merged
merged 2 commits into from
Jan 10, 2025
Merged

Gracefully handle incorrect command aliases #1059

merged 2 commits into from
Jan 10, 2025

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jan 3, 2025

Even if the aliased target is a helper method or does not exist, IRB should not crash.

This commit warns users in such cases and treat the input as normal expression.

Fixes #992

Even if the aliased target is a helper method or does not exist, IRB
should not crash.

This commit warns users in such cases and treat the input as normal expression.
@st0012 st0012 added the bug Something isn't working label Jan 3, 2025
@st0012 st0012 self-assigned this Jan 3, 2025
message = <<~MESSAGE
Using command alias `#{command}` for helper method `#{aliased_name}` is not supported.
Please check the value of `IRB.conf[:COMMAND_ALIASES]`.
MESSAGE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving this message generating part into IncorrectAlias and just return Statement::IncorrectAlias.new(aliased_name) here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that means we'll be querying registered helper methods from a Statement class, which IMO is a bad coupling. I think this type of interaction is better happen inside Context or Irb?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. 👍

@st0012 st0012 merged commit 9fc14eb into master Jan 10, 2025
67 checks passed
@st0012 st0012 deleted the fix-#992 branch January 10, 2025 21:29
matzbot pushed a commit to ruby/ruby that referenced this pull request Jan 10, 2025
(ruby/irb#1059)

* Gracefully handle incorrect command aliases

Even if the aliased target is a helper method or does not exist, IRB
should not crash.

This commit warns users in such cases and treat the input as normal expression.

* Streamline command parsing and introduce warnings for incorrect command aliases

ruby/irb@9fc14eb74b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

next alias crashing
2 participants