Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
rparker opened this Issue · 10 comments

5 participants

@rparker

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

For example: c = 2

@rparker

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...

@nixme
Owner

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

@banister
Collaborator

@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?

@nixme
Owner

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

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.

@nixme
Owner

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

@ConradIrwin

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).

@lucapette

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?

@nixme
Owner

Aliases removed in version 0.2.0 (released yesterday).

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

@nixme nixme closed this
@lucapette

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.