Skip to content

Commit adccafb

Browse files
committed
tests/basics/lexer: Add a test for newline-escaping within a string.
1 parent 1b44987 commit adccafb

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

py/lexer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ STATIC void mp_lexer_next_token_into(mp_lexer_t *lex, bool first_token) {
431431
} else {
432432
switch (c) {
433433
case MP_LEXER_EOF: break; // TODO a proper error message?
434-
case '\n': c = MP_LEXER_EOF; break; // TODO check this works correctly (we are supposed to ignore it
434+
case '\n': c = MP_LEXER_EOF; break; // backslash escape the newline, just ignore it
435435
case '\\': break;
436436
case '\'': break;
437437
case '"': break;

tests/basics/lexer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
print(eval("12\r"))
2020
print(eval("123\r"))
2121

22+
# backslash used to escape a line-break in a string
23+
print('a\
24+
b')
25+
2226
# lots of indentation
2327
def a(x):
2428
if x:

0 commit comments

Comments
 (0)