File tree 2 files changed +7
-1
lines changed
src/compiler/crystal/syntax
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,8 @@ describe "Lexer" do
456
456
assert_syntax_error " '\\ u{110000}'" , " invalid unicode codepoint (too large)"
457
457
assert_syntax_error " :+1" , " unexpected token"
458
458
459
+ assert_syntax_error " '\\ 1'" , " invalid char escape sequence"
460
+
459
461
it_lexes_string %( "\\ 1") , String .new(Bytes [1 ])
460
462
it_lexes_string %( "\\ 4") , String .new(Bytes [4 ])
461
463
it_lexes_string %( "\\ 10") , String .new(Bytes [8 ])
Original file line number Diff line number Diff line change @@ -587,6 +587,10 @@ module Crystal
587
587
case char1 = next_char
588
588
when '\\ '
589
589
case char2 = next_char
590
+ when '\\ '
591
+ @token .value = '\\ '
592
+ when '\' '
593
+ @token .value = '\' '
590
594
when 'b'
591
595
@token .value = '\b'
592
596
when 'e'
@@ -609,7 +613,7 @@ module Crystal
609
613
when '\0'
610
614
raise " unterminated char literal" , line, column
611
615
else
612
- @token .value = char2
616
+ raise " invalid char escape sequence " , line, column
613
617
end
614
618
when '\' '
615
619
raise " invalid empty char literal (did you mean '\\\' '?)" , line, column
You can’t perform that action at this time.
0 commit comments