@@ -751,8 +751,23 @@ fn (mut c Checker) call_expr(mut node ast.CallExpr) ast.Type {
751
751
c.inside_or_block_value = true
752
752
c.check_or_expr (node.or_block, typ, c.expected_or_type, node)
753
753
c.inside_or_block_value = old_inside_or_block_value
754
+ } else if node.or_block.kind == .propagate_option || node.or_block.kind == .propagate_result {
755
+ if c.pref.skip_unused && ! c.is_builtin_mod && c.mod != 'strings' {
756
+ c.table.used_features.option_or_result = true
757
+ }
754
758
}
755
759
c.expected_or_type = old_expected_or_type
760
+ if c.pref.skip_unused && ! c.is_builtin_mod && c.mod == 'main' {
761
+ if node.is_method {
762
+ type_str := c.table.type_to_str (node.left_type)
763
+ if c.table.sym (node.left_type).is_builtin ()
764
+ && type_str ! in c.table.used_features.used_modules {
765
+ c.table.used_features.used_modules[type_str] = true
766
+ }
767
+ } else if node.name.contains ('.' ) {
768
+ c.table.used_features.used_modules[node.name.all_before ('.' )] = true
769
+ }
770
+ }
756
771
757
772
if ! c.inside_const && c.table.cur_fn != unsafe { nil } && ! c.table.cur_fn.is_main
758
773
&& ! c.table.cur_fn.is_test {
@@ -1401,7 +1416,8 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
1401
1416
// println / eprintln / panic can print anything
1402
1417
if node.args.len > 0 && fn_name in print_everything_fns {
1403
1418
c.builtin_args (mut node, fn_name, func)
1404
- if c.pref.skip_unused && ! c.is_builtin_mod && node.args[0 ].expr ! is ast.StringLiteral {
1419
+ if c.pref.skip_unused && ! c.is_builtin_mod && c.mod != 'math.bits'
1420
+ && node.args[0 ].expr ! is ast.StringLiteral {
1405
1421
if ! c.table.sym (c.unwrap_generic (node.args[0 ].typ)).has_method ('str' ) {
1406
1422
c.table.used_features.auto_str = true
1407
1423
if node.args[0 ].typ.is_ptr () {
@@ -2162,9 +2178,6 @@ fn (mut c Checker) method_call(mut node ast.CallExpr, mut continue_check &bool)
2162
2178
continue_check = false
2163
2179
return ast.void_type
2164
2180
}
2165
- if c.pref.skip_unused && ! c.is_builtin_mod && c.mod != 'strings' {
2166
- c.table.used_features.builtin_types = true
2167
- }
2168
2181
c.expected_type = left_type
2169
2182
mut is_generic := left_type.has_flag (.generic)
2170
2183
node.left_type = left_type
@@ -2949,6 +2962,9 @@ fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) !
2949
2962
}
2950
2963
if f.is_variadic {
2951
2964
min_required_params--
2965
+ if c.pref.skip_unused && ! c.is_builtin_mod {
2966
+ c.table.used_features.arr_init = true
2967
+ }
2952
2968
} else {
2953
2969
has_decompose := node.args.any (it .expr is ast.ArrayDecompose )
2954
2970
if has_decompose {
@@ -3565,7 +3581,7 @@ fn (mut c Checker) array_builtin_method_call(mut node ast.CallExpr, left_type as
3565
3581
}
3566
3582
node.return_type = ast.int_type
3567
3583
} else if method_name in ['first' , 'last' , 'pop' ] {
3568
- if c.pref.skip_unused {
3584
+ if c.pref.skip_unused && ! c.is_builtin_mod {
3569
3585
if method_name == 'first' {
3570
3586
c.table.used_features.arr_first = true
3571
3587
}
@@ -3587,6 +3603,9 @@ fn (mut c Checker) array_builtin_method_call(mut node ast.CallExpr, left_type as
3587
3603
node.receiver_type = node.left_type
3588
3604
}
3589
3605
} else if method_name == 'delete' {
3606
+ if c.pref.skip_unused && ! c.is_builtin_mod {
3607
+ c.table.used_features.arr_delete = true
3608
+ }
3590
3609
c.check_for_mut_receiver (mut node.left)
3591
3610
unwrapped_left_sym := c.table.sym (unwrapped_left_type)
3592
3611
if method := c.table.find_method (unwrapped_left_sym, method_name) {
0 commit comments