Clojure

Error reporting of invalid digit in unicode character literal

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: Release 1.2, Release 1.3
  • Fix Version/s: Release 1.4
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code
  • Approval:
    Ok

Description

I ran across the following code when reading unicode character literals in readUnicodeChar(String token, int offset, int length, int base)

 
int d = Character.digit(token.charAt(i), base);
if(d == -1)
    throw new IllegalArgumentException("Invalid digit: " + (char) d);

Casting -1 to a char doesn't seem to produce anything useful. I'm guessing the appropriate code might look like

 
int d = Character.digit(token.charAt(i), base);
if(d == -1)
    throw new IllegalArgumentException("Invalid digit: " + token.charAt(i));

For comparison, the code in the other readUnicodeCharacter used when reading strings handles this correctly with:

int d = Character.digit(ch, base);
if(d == -1)
    throw new IllegalArgumentException("Invalid digit: " + (char) ch); 

Activity

Hide
Cosmin Stejerean added a comment -

Attached a patch with the minor code fix.

Show
Cosmin Stejerean added a comment - Attached a patch with the minor code fix.
Cosmin Stejerean made changes -
Field Original Value New Value
Attachment CLJ-924-unicode-invalid-digit.patch [ 10890 ]
Cosmin Stejerean made changes -
Patch Code [ 10001 ]
Hide
Stuart Sierra added a comment -

Screened. I can't demonstrate this code being called by the reader, but it seems to be correct.

Show
Stuart Sierra added a comment - Screened. I can't demonstrate this code being called by the reader, but it seems to be correct.
Stuart Sierra made changes -
Approval Screened [ 10004 ]
Hide
Andy Fingerhut added a comment -

Sorry to disturb things after this has been screened, but clj-924-unicode-invalid-digit-patch2.txt has some added tests that cause the problem to occur, as well as one other similar one nearby in LispReader.java, which is also fixed, in addition to Cosmin's fix.

Show
Andy Fingerhut added a comment - Sorry to disturb things after this has been screened, but clj-924-unicode-invalid-digit-patch2.txt has some added tests that cause the problem to occur, as well as one other similar one nearby in LispReader.java, which is also fixed, in addition to Cosmin's fix.
Andy Fingerhut made changes -
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Affects Version/s Release 1.4 [ 10040 ]
Fix Version/s Release 1.4 [ 10040 ]
Stuart Halloway made changes -
Resolution Completed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: