Skip to content

Commit 27e1c20

Browse files
authored
toml: fix multiline array bool scanner, add test (#18068)
1 parent b767c7d commit 27e1c20

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

vlib/toml/scanner/scanner.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub fn (mut s Scanner) scan() !token.Token {
142142

143143
if util.is_key_char(byte_c) {
144144
key := s.extract_key()
145-
if !s.is_left_of_assign && (key == 'true' || key == 'false') {
145+
if u8(s.peek(1)) != `=` && (key == 'true' || key == 'false') {
146146
util.printdbg(@MOD + '.' + @STRUCT + '.' + @FN, 'identified a boolean "${key}" (${key.len})')
147147
return s.new_token(.boolean, key, key.len)
148148
}

vlib/toml/tests/reflect_test.v

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ strings = [
1616
1717
bools = [true, false, true, true]
1818
19+
bools_br = [
20+
true,
21+
false,
22+
true,
23+
true
24+
]
25+
1926
floats = [0.0, 1.0, 2.0, 3.0]
2027
2128
floats_br = [
@@ -57,6 +64,7 @@ struct User {
5764
birthday toml.Date
5865
strings []string
5966
bools []bool
67+
bools_br []bool
6068
floats []f32
6169
floats_br []f32
6270
int_map map[string]int
@@ -80,6 +88,7 @@ fn test_reflect() {
8088
assert user.birthday.str() == '1980-04-23'
8189
assert user.strings == ['v matures', 'like rings', 'spread in the', 'water']
8290
assert user.bools == [true, false, true, true]
91+
assert user.bools_br == [true, false, true, true]
8392
assert user.floats == [f32(0.0), 1.0, 2.0, 3.0]
8493
assert user.floats_br == [f32(0.0), 1.05, 2.025, 3.5001]
8594
assert user.int_map == {

0 commit comments

Comments
 (0)