File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
src/compiler/crystal/syntax Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,8 @@ describe "Lexer" do
456456 assert_syntax_error " '\\ u{110000}'" , " invalid unicode codepoint (too large)"
457457 assert_syntax_error " :+1" , " unexpected token"
458458
459+ assert_syntax_error " '\\ 1'" , " invalid char escape sequence"
460+
459461 it_lexes_string %( "\\ 1") , String .new(Bytes [1 ])
460462 it_lexes_string %( "\\ 4") , String .new(Bytes [4 ])
461463 it_lexes_string %( "\\ 10") , String .new(Bytes [8 ])
Original file line number Diff line number Diff line change @@ -587,6 +587,10 @@ module Crystal
587587 case char1 = next_char
588588 when '\\ '
589589 case char2 = next_char
590+ when '\\ '
591+ @token .value = '\\ '
592+ when '\' '
593+ @token .value = '\' '
590594 when 'b'
591595 @token .value = '\b'
592596 when 'e'
@@ -609,7 +613,7 @@ module Crystal
609613 when '\0'
610614 raise " unterminated char literal" , line, column
611615 else
612- @token .value = char2
616+ raise " invalid char escape sequence " , line, column
613617 end
614618 when '\' '
615619 raise " invalid empty char literal (did you mean '\\\' '?)" , line, column
You can’t perform that action at this time.
0 commit comments