Skip to content

Commit 195f161

Browse files
authored
markused: fix option tracking on sumtype (fix #25025) (#25028)
1 parent 07ce904 commit 195f161

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import json
2+
3+
type Any = string | f32 | bool | ?int
4+
5+
fn test_main() {
6+
x := json.decode([]Any, '["hi", -9.8e7, true, null]')!
7+
assert dump(x) == [Any('hi'), Any(f32(-9.8e+7)), Any(true), Any('')]
8+
}

vlib/v/markused/walker.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,9 @@ pub fn (mut w Walker) mark_by_sym(isym ast.TypeSymbol) {
11611161
w.features.used_maps++
11621162
continue
11631163
}
1164+
if typ.has_flag(.option) {
1165+
w.used_option++
1166+
}
11641167
w.mark_by_type(typ)
11651168
}
11661169
}

0 commit comments

Comments
 (0)