Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reflection.type_of panics for C strings #19595

Closed
magic003 opened this issue Oct 18, 2023 · 0 comments · Fixed by #19599
Closed

reflection.type_of panics for C strings #19595

magic003 opened this issue Oct 18, 2023 · 0 comments · Fixed by #19599
Labels
Bug This tag is applied to issues which reports bugs. Unit: Type System Bugs/feature requests, that are related to the V types system.

Comments

@magic003
Copy link

magic003 commented Oct 18, 2023

Describe the bug

The reflection.type_of[T](v T) panics when it is called with a C string value.

Reproduction Steps

module main

import v.reflection

fn main() {
    s := c'test'
    println(reflection.type_of(s))
}

Expected Behavior

It prints the type of C string.

Current Behavior

It prints the following error:

V panic: array.get: index out of range (i == 0, a.len == 0)
v hash: 44045c6
0   .noprefix.01HD1GJ6XZ0HNB7KWRHMZD7NF 0x0000000101fecc39 array_get + 249
1   .noprefix.01HD1GJ6XZ0HNB7KWRHMZD7NF 0x0000000102043b4c v__reflection__type_of_T___ptr__u8 + 300
2   .noprefix.01HD1GJ6XZ0HNB7KWRHMZD7NF 0x0000000102046033 main__main + 35
3   .noprefix.01HD1GJ6XZ0HNB7KWRHMZD7NF 0x00000001020b5977 main + 71
4   dyld                                0x00007ff816f0e3a6 start + 1942

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.2 44045c6

Environment details (OS name and version, etc.)

V full version: V 0.4.2 44045c6
OS: macos, macOS, 14.0, 23A344
Processor: 12 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz

getwd: /private/tmp
vexe: /Users/<user_name>/workspace/v/v
vexe mtime: 2023-10-16 00:41:11

vroot: OK, value: /Users/<user_name>/workspace/v
VMODULES: OK, value: /Users/<user_name>/.vmodules
VTMP: OK, value: /tmp/v_501

env VFLAGS: "-use-os-system-to-run"

Git version: git version 2.33.0
Git vroot status: weekly.2023.41-20-g44045c65 (9 commit(s) behind V master)
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.0.40.1)
thirdparty/tcc status: thirdparty-macos-amd64 46662e2

Note

You can vote for this issue using the 👍 reaction. More votes increase the issue's priority for developers.

Take into account that only the 👍 reaction counts as a vote.
Only reactions to the issue itself will be counted as votes, not comments.

@magic003 magic003 added the Bug This tag is applied to issues which reports bugs. label Oct 18, 2023
@ArtemkaKun ArtemkaKun added the Unit: Type System Bugs/feature requests, that are related to the V types system. label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: Type System Bugs/feature requests, that are related to the V types system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants