Skip to content

Commit

Permalink
Fixes #3778. Unicode chars in method names aren't accepted
Browse files Browse the repository at this point in the history
This was pretty simple fix.  Our constant character check used Java's
isUpperCase but we only gave the first byte of the codepoint.  So I
changed this to be the first character.
enebo committed Aug 17, 2016
1 parent 30594f4 commit cc1743c
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions core/src/main/java/org/jruby/ext/ripper/RipperLexer.java
Original file line number Diff line number Diff line change
@@ -1601,7 +1601,6 @@ private int identifier(int c, boolean commandState) throws IOException {
// and this hack can disappear.
int whereKeywordShouldStart = lex_p - 1;

int first = c;
do {
if (!tokadd_mbchar(c)) return EOF;
c = nextc();
@@ -1622,9 +1621,11 @@ private int identifier(int c, boolean commandState) throws IOException {

int result = 0;

String tempVal;
last_state = lex_state;
if (lastBangOrPredicate) {
result = Tokens.tFID;
tempVal = createTokenString();
} else {
if (isLexState(lex_state, EXPR_FNAME)) {
if ((c = nextc()) == '=') {
@@ -1642,15 +1643,14 @@ private int identifier(int c, boolean commandState) throws IOException {
pushback(c);
}
}
if (result == 0 && Character.isUpperCase(first)) {
tempVal = createTokenString();
if (result == 0 && Character.isUpperCase(tempVal.charAt(0))) {
result = Tokens.tCONSTANT;
} else {
result = Tokens.tIDENTIFIER;
}
}

String tempVal = createTokenString();

if (isLabelPossible(commandState)) {
if (isLabelSuffix()) {
setState(EXPR_ARG|EXPR_LABELED);
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
Original file line number Diff line number Diff line change
@@ -1443,7 +1443,6 @@ private int identifier(int c, boolean commandState) throws IOException {
}

newtok(true);
int first = c;
do {
if (!tokadd_mbchar(c)) return EOF;
c = nextc();
@@ -1465,8 +1464,10 @@ private int identifier(int c, boolean commandState) throws IOException {
int result = 0;

last_state = lex_state;
String tempVal;
if (lastBangOrPredicate) {
result = Tokens.tFID;
tempVal = createTokenString();
} else {
if (isLexState(lex_state, EXPR_FNAME)) {
if ((c = nextc()) == '=') {
@@ -1484,14 +1485,14 @@ private int identifier(int c, boolean commandState) throws IOException {
pushback(c);
}
}
tempVal = createTokenString();

if (result == 0 && Character.isUpperCase(first)) {
if (result == 0 && Character.isUpperCase(tempVal.charAt(0))) {
result = Tokens.tCONSTANT;
} else {
result = Tokens.tIDENTIFIER;
}
}
String tempVal = createTokenString();

if (isLabelPossible(commandState)) {
if (isLabelSuffix()) {

0 comments on commit cc1743c

Please sign in to comment.