Skip to content

Commit

Permalink
More accurate valid instance variable method.
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Apr 16, 2018
1 parent df5f4a0 commit 5b69642
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/RubySymbol.java
Expand Up @@ -228,7 +228,8 @@ public boolean validConstantName() {
public boolean validInstanceVariableName() {
boolean valid = ByteListHelper.eachCodePoint(getBytes(), (int index, int codepoint, Encoding encoding) ->
index == 0 && codepoint == '@' ||
index != 0 && (encoding.isAlnum(codepoint) || !Encoding.isAscii(codepoint) || codepoint == '_'));
index == 1 && (!encoding.isDigit(codepoint)) && (encoding.isAlnum(codepoint) || !Encoding.isAscii(codepoint) || codepoint == '_') ||
index > 1 && (encoding.isAlnum(codepoint) || !Encoding.isAscii(codepoint) || codepoint == '_'));

return valid && getBytes().length() >= 2; // FIXME: good enough on length check? Trying to avoid counter.
}
Expand Down

0 comments on commit 5b69642

Please sign in to comment.