markused: fix option tracking on sumtype (fix #25025) (#25028)

This commit is contained in:
Felipe Pena 2025-08-03 04:12:32 -03:00 committed by GitHub
parent 07ce904431
commit 195f1612f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,8 @@
import json
type Any = string | f32 | bool | ?int
fn test_main() {
x := json.decode([]Any, '["hi", -9.8e7, true, null]')!
assert dump(x) == [Any('hi'), Any(f32(-9.8e+7)), Any(true), Any('')]
}

View File

@ -1161,6 +1161,9 @@ pub fn (mut w Walker) mark_by_sym(isym ast.TypeSymbol) {
w.features.used_maps++
continue
}
if typ.has_flag(.option) {
w.used_option++
}
w.mark_by_type(typ)
}
}