parser: fix string interpolation for default conversion

pull/4693/head
Uwe Krüger 2020-05-03 18:12:59 +02:00 committed by GitHub
parent de749e9d3b
commit 4a096bd133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -900,7 +900,7 @@ fn (mut p Parser) string_expr() ast.Expr {
efmt << p.tok.lit
p.next()
}
if p.tok.lit.len == 1 {
if p.tok.kind == .name && p.tok.lit.len == 1 {
efmt << p.tok.lit
p.next()
}

View File

@ -77,6 +77,8 @@ fn test_string_interpolation_string_prefix() {
}
fn test_inttypes_string_interpolation() {
c := i8(-103)
uc := byte(217)
s := i16(-23456)
us := u16(54321)
i := -1622999040
@ -86,8 +88,9 @@ fn test_inttypes_string_interpolation() {
assert '$s $us' == '-23456 54321'
assert '$ui $i' == '3421958087 -1622999040'
assert '$l $ul' == '-7694555558525237396 17234006112912956370'
assert '>${s:11}< >${us:-13}<-' == '> -23456< >54321 <-'
assert '0x${ul:-19x}< >${l:22d}<-' == '0xef2b7d4001165bd2 < > -7694555558525237396<-'
assert '>${s:11}:${us:-13}<' == '> -23456:54321 <'
assert '0x${ul:-19x}:${l:22d}' == '0xef2b7d4001165bd2 : -7694555558525237396'
assert '${c:5}${uc:-7}x' == ' -103217 x'
}
fn test_utf8_string_interpolation() {