mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
075c025999
commit
5fe4888874
@ -208,8 +208,13 @@ fn (mut p Parser) map_init() ast.MapInit {
|
|||||||
mut comments := [][]ast.Comment{}
|
mut comments := [][]ast.Comment{}
|
||||||
pre_cmnts := p.eat_comments()
|
pre_cmnts := p.eat_comments()
|
||||||
for p.tok.kind !in [.rcbr, .eof] {
|
for p.tok.kind !in [.rcbr, .eof] {
|
||||||
key := p.expr(0)
|
if p.tok.kind == .name && p.tok.lit in ['r', 'c', 'js'] {
|
||||||
keys << key
|
key := p.string_expr()
|
||||||
|
keys << key
|
||||||
|
} else {
|
||||||
|
key := p.expr(0)
|
||||||
|
keys << key
|
||||||
|
}
|
||||||
p.check(.colon)
|
p.check(.colon)
|
||||||
val := p.expr(0)
|
val := p.expr(0)
|
||||||
vals << val
|
vals << val
|
||||||
|
10
vlib/v/tests/map_test.v
Normal file
10
vlib/v/tests/map_test.v
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// For issue 16285 Raw string in map literal key triggers compiler error
|
||||||
|
fn test_raw_string_as_key() {
|
||||||
|
mut m := {
|
||||||
|
r'key': 1
|
||||||
|
}
|
||||||
|
assert m[r'key'] == 1
|
||||||
|
|
||||||
|
m[r'key'] = 2
|
||||||
|
assert m[r'key'] == 2
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user