Assignment to 'c' is confused with abbreviated 'continue' command #3

Closed
rparker opened this Issue Jan 16, 2012 · 10 comments

Comments

Projects
None yet
5 participants

rparker commented Jan 16, 2012

Innocent assignment to 'c' produces: Error: Cannot find local context. Did you use binding.pry?

For example: c = 2

rparker commented Jan 16, 2012

Note that querying the value of 'c' is also a problem, so a fix that simply looks for a following assignment operator is not good enough...

Owner

nixme commented Jan 17, 2012

Not sure if there's an easy fix. Perhaps I should just remove the aliases?

Collaborator

banister commented Jan 17, 2012

@nixme @parker If there is demand to further disambiguate commands from ruby code we can do a couple of things:

(1) Show a warning when collisions occur
(2) Support an optional mode toggle for a command mode and a code mode (so no conflicts can occur)

Any of these appeal to either of you? any other suggestions?

Owner

nixme commented Jan 18, 2012

Both sound like possible solutions.

Just thinking out loud, but what about two modes: the current one where commands and code are intermixed, and one where only commands work. Short aliases, like 'c', would only be enabled in command-only mode where they'd have more utility.

rparker commented Jan 23, 2012

Dual modes, like 'vi', seems like too much of a change.

I'd be happy just to get a warning about the variable-name / command collision... The problem right now is that the error message does not lead you to an understanding of the problem.

Owner

nixme commented Jan 24, 2012

Got it. I can improve the error messaging in the next release.

Contributor

ConradIrwin commented Mar 15, 2012

This has been reported as a bug in pry (again): pry/pry#492

We've got an experimental feature that warns the user when this happens, but a better fix is to not destroy the single-letter namespace by default (from my own experience that's the kind of variable name that I use most often while in a REPL).

I was just going to report the issue in pry too. A search brought me here.

@ConradIrwin is right IMHO. It's very common to use single letters in a REPL for variables. Probably, you should consider removing them. Or is there a way to override the alias with the variables and just show a warning message? But that can be annoying anyway... What do you think?

Owner

nixme commented Mar 20, 2012

Aliases removed in version 0.2.0 (released yesterday).

A note added to the README about adding aliases to ~/.pryrc

nixme closed this Mar 20, 2012

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment