diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java index febee59455a..0fa2aa91a7d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java @@ -182,11 +182,11 @@ public class CompileTimeConstantResolver { } // Strip the quotes - if (text.charAt(0) != '\'' || text.charAt(text.length() - 1) != '\'') { + if (text.length() < 2 || text.charAt(0) != '\'' || text.charAt(text.length() - 1) != '\'') { return new ErrorValue("Incorrect character literal"); } text = text.substring(1, text.length() - 1); // now there're no quotes - + if (text.length() == 0) { return new ErrorValue("Empty character literal"); } diff --git a/compiler/testData/diagnostics/tests/CharacterLiterals.jet b/compiler/testData/diagnostics/tests/CharacterLiterals.jet new file mode 100644 index 00000000000..9942668c574 --- /dev/null +++ b/compiler/testData/diagnostics/tests/CharacterLiterals.jet @@ -0,0 +1,13 @@ +fun test(c : Char) { + test('') + test('a') + test('aa') + test('a) + test(' + test(0' + test('\n') + test('\\') + test('''') + test('\'') + test('\"') +}