1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: escapes quote on literals

This commit is contained in:
Henrixounez 2019-09-11 14:21:20 +02:00 committed by Alexander Medvednikov
parent 949dfc59fd
commit af60f9ead4
2 changed files with 7 additions and 1 deletions

View File

@ -752,7 +752,8 @@ fn (s mut Scanner) ident_char() string {
s.error('invalid character literal (more than one character: $len)') s.error('invalid character literal (more than one character: $len)')
} }
} }
return c // Escapes a `'` character
return if c == '\'' { '\\' + c } else { c }
} }
fn (s mut Scanner) peek() Token { fn (s mut Scanner) peek() Token {

View File

@ -418,3 +418,8 @@ fn test_for_loop_two() {
assert c == s[i] assert c == s[i]
} }
} }
fn test_quote() {
a := `'`
assert a.str() == '\''
}