-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.Unit: markusedBugs/feature requests, that are related to the -skip-unused.Bugs/feature requests, that are related to the -skip-unused.
Description
Describe the bug
Because markused is not work as expected, there are some extra code in final generated C code.
It may related to bug found at #25997 (comment)_
Reproduction Steps
g.v
module main
fn new[T]() map[u8]T {
x := map[u8]T{}
return x
}
fn not_used_fn() map[u8]int {
x := new[int]()
return x
}
fn main() {
x := new[u32]()
dump(x)
}Expected Behavior
final C code should contain only following code:
VV_LOC Map_u8_u32 main__new_T_u32(void) {
Map_u8_u32 x = builtin__new_map_noscan_key_value(sizeof(u8), sizeof(u32), &builtin__map_hash_int_1, &builtin__map_eq_int_1, &builtin__map_clone_int_1, &builtin__map_free_nop)
;
return x;
}
VV_LOC void main__main(void) {
Map_u8_u32 x = main__new_T_u32();
_v_dump_expr_Map_u8_u32(_S("g.v"), 15, _S("x"), x);
}Current Behavior
extra code exist in C code:
VV_LOC Map_u8_int main__new_T_int(void) { // this should not exist in final C code!
Map_u8_int x = builtin__new_map_noscan_key_value(sizeof(u8), sizeof(int), &builtin__map_hash_int_1, &builtin__map_eq_int_1, &builtin__map_clone_int_1, &builtin__map_free_nop)
;
return x;
}
VV_LOC Map_u8_u32 main__new_T_u32(void) {
Map_u8_u32 x = builtin__new_map_noscan_key_value(sizeof(u8), sizeof(u32), &builtin__map_hash_int_1, &builtin__map_eq_int_1, &builtin__map_clone_int_1, &builtin__map_free_nop)
;
return x;
}
VV_LOC void main__main(void) {
Map_u8_u32 x = main__new_T_u32();
_v_dump_expr_Map_u8_u32(_S("g.v"), 15, _S("x"), x);
}Possible Solution
One option: reset all concrete_types to empty before enter markused, then use markused add all used concrete_types back.
Additional Information/Context
No response
V version
V 0.4.12 967a4a2
Environment details (OS name and version, etc.)
| V full version | V 0.4.12 967a4a2 |
|---|---|
| OS | linux, Ubuntu 24.04.3 LTS |
| Processor | 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz |
| Memory | 10.91GB/15.51GB |
| V executable | /media/HD/github/kbkpbot/v/v |
| V last modified time | 2025-12-18 12:58:41 |
| V home dir | OK, value: /media/HD/github/kbkpbot/v |
| VMODULES | OK, value: /home/mars/.vmodules |
| VTMP | OK, value: /tmp/v_1000 |
| Current working dir | OK, value: /home/mars |
| Git version | git version 2.43.0 |
| V git status | weekly.2025.46-227-g636527a4-dirty |
| .git/config present | true |
| cc version | cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 |
| gcc version | gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0 |
| clang version | Ubuntu clang version 18.1.3 (1ubuntu1) |
| tcc version | tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux) |
| tcc git status | thirdparty-linux-amd64 696c1d84 |
| emcc version | N/A |
| glibc version | ldd (Ubuntu GLIBC 2.39-0ubuntu8.6) 2.39 |
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
Metadata
Metadata
Assignees
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.Unit: markusedBugs/feature requests, that are related to the -skip-unused.Bugs/feature requests, that are related to the -skip-unused.