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

Add ruby predefined objects to variable name checker #94

Merged
merged 1 commit into from
Nov 18, 2017

Conversation

styd
Copy link
Contributor

@styd styd commented Nov 17, 2017

Hi, @yuki24.
I'm thinking of adding predefined objects (false, true, and nil) in the variable name checker dictionary. Their 2.4 deprecated toplevel constants are already included, but the objects themselves are not.
The constants:

a = NOL
# NameError: uninitialized constant NOL
# Did you mean?  NIL
b = FALS
# NameError: uninitialized constant FALS
# Did you mean?  FALSE
c = TREU
# NameError: uninitialized constant TREU
# Did you mean?  TRUE

but, the objects:

a = nol
# NameError: undefined local variable or method `nol' for main:Object
b = fals
# NameError: undefined local variable or method `fals' for main:Object
c = treu
# NameError: undefined local variable or method `treu' for main:Object

I need to be reminded of these objects too.

I don't know how to get the predefined objects in the nice way so I just write them in an array.
Since nil return "" when called with to_s, I replaced it with :nil.
Should I wrote all of them in symbols ([:false, :true, :nil]) to make it consistent with the others?

If this PR is merged:

a = nol
# NameError: undefined local variable or method `nol' for main:Object
# Did you mean?  nil
b = fals
# NameError: undefined local variable or method `fals' for main:Object
# Did you mean?  false
c = treu
# NameError: undefined local variable or method `treu' for main:Object
# Did you mean?  true

@yuki24
Copy link
Member

yuki24 commented Nov 18, 2017

This is a great addition. Thanks!

@yuki24 yuki24 merged commit 7ebbd23 into ruby:master Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants