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 7a1e1953cb2..7a1d4ffebde 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 @@ -164,14 +164,21 @@ public class CompileTimeConstantResolver { if (error != null) { return error; } - assert text.charAt(0) == '\'' && text.charAt(text.length() - 1) == '\''; + + if (text.charAt(0) != '\'' || text.charAt(text.length() - 1) != '\'') { + return new ErrorValue("Incorret character constant"); + } text = text.substring(1, text.length() - 1); if (text.length() == 0) { return new ErrorValue("Empty character literal"); } else if (text.length() == 1) { - return new CharValue(text.charAt(0)); + if (text.charAt(0) == '\\') { + return new ErrorValue("Illegal escape: " + text); + } else { + return new CharValue(text.charAt(0)); + } } else if (text.length() == 2 && text.charAt(0) == '\\') { Character escaped = translateEscape(text.charAt(1)); if (escaped == null) { diff --git a/compiler/testData/checkerWithErrorTypes/quick/IncorrectCharacterLiterals.jet b/compiler/testData/checkerWithErrorTypes/quick/IncorrectCharacterLiterals.jet index fcc34e9e44f..5808615db0f 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/IncorrectCharacterLiterals.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/IncorrectCharacterLiterals.jet @@ -4,6 +4,9 @@ fun ff() { val b = '' val c = '23' + val d = 'a + val e = 'ab + val f = '\' } fun test() { @@ -20,4 +23,4 @@ fun test() { '\123' '\ra' '\000' -} \ No newline at end of file +}