The \u000d
escape terminates a comment because \u
escapes are uniformly converted to the corresponding Unicode characters before the program is tokenized. You could equally use \u0057\u0057
instead of //
to begin a comment.
This is a bug in your IDE, which should syntax-highlight the line to make it clear that the \u000d
ends the comment.
This is also a design error in the language. It can't be corrected now, because that would break programs that depend on it. \u
escapes should either be converted to the corresponding Unicode character by the compiler only in contexts where that "makes sense" (string literals and identifiers, and probably nowhere else) or they should have been forbidden to generate characters in the U+0000–007F range, or both. Either of those semantics would have prevented the comment from being terminated by the \u000d
escape, without interfering with the cases where \u
escapes are useful—note that that includes use of \u
escapes inside comments as a way to encode comments in a non-Latin script, because the text editor could take a broader view of where \u
escapes are significant than the compiler does. (I am not aware of any editor or IDE that will display \u
escapes as the corresponding characters in any context, though.)
There is a similar design error in the C family,1 where backslash-newline is processed before comment boundaries are determined, so e.g.
// this is a comment \
this is still in the comment!
I bring this up to illustrate that it happens to be easy to make this particular design error, and not realize that it's an error until it is too late to correct it, if you are used to thinking about tokenization and parsing the way compiler programmers think about tokenization and parsing. Basically, if you have already defined your formal grammar and then someone comes up with a syntactic special case — trigraphs, backslash-newline, encoding arbitrary Unicode characters in source files limited to ASCII, whatever — that needs to be wedged in, it's easier to add a transformation pass before the tokenizer than it is to redefine the tokenizer to pay attention to where it makes sense to use that special case.
1 For pedants: I am aware that this aspect of C was 100% intentional, with the rationale — I am not making this up — that it would allow you to mechanically force-fit code with arbitrarily long lines onto punched cards. It was still an incorrect design decision.