@@ -3137,6 +3137,10 @@ pub fn (mut c Checker) expr(mut node ast.Expr) ast.Type {
31373137 c.inside_if_guard = true
31383138 node.expr_type = c.expr (mut node.expr)
31393139 c.inside_if_guard = old_inside_if_guard
3140+ if c.pref.skip_unused && node.expr_type.has_flag (.generic) {
3141+ unwrapped_type := c.unwrap_generic (node.expr_type)
3142+ c.table.used_features.comptime_syms[unwrapped_type] = true
3143+ }
31403144 if ! node.expr_type.has_flag (.option) && ! node.expr_type.has_flag (.result) {
31413145 mut no_opt_or_res := true
31423146 match mut node.expr {
@@ -3435,6 +3439,9 @@ fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
34353439 // allow conversion from none to every option type
34363440 } else if to_sym.kind == .sum_type {
34373441 to_sym_info := to_sym.info as ast.SumType
3442+ if c.pref.skip_unused && to_sym_info.concrete_types.len > 0 {
3443+ c.table.used_features.comptime_syms[to_type] = true
3444+ }
34383445 if to_sym_info.generic_types.len > 0 && to_sym_info.concrete_types.len == 0 {
34393446 c.error ('generic sumtype `${to_sym .name }` must specify type parameter, e.g. ${to_sym .name }[int]' ,
34403447 node.pos)
@@ -5227,6 +5234,9 @@ fn (mut c Checker) chan_init(mut node ast.ChanInit) ast.Type {
52275234 if node.has_cap {
52285235 c.check_array_init_para_type ('cap' , mut node.cap_expr, node.pos)
52295236 }
5237+ if c.pref.skip_unused && node.typ.has_flag (.generic) {
5238+ c.table.used_features.comptime_syms[c.unwrap_generic (node.typ)] = true
5239+ }
52305240 return node.typ
52315241 } else {
52325242 c.error ('`chan` of unknown type' , node.pos)
0 commit comments