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

after v fmt cause compile error #21767

Closed
kbkpbot opened this issue Jun 30, 2024 · 0 comments · Fixed by #21786
Closed

after v fmt cause compile error #21767

kbkpbot opened this issue Jun 30, 2024 · 0 comments · Fixed by #21786
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@kbkpbot
Copy link
Contributor

kbkpbot commented Jun 30, 2024

Describe the bug

v fmt create a new v file, will cause compile error

Reproduction Steps

test.v

module main

const spnames = ['abc', (voidptr(0))]!

fn main() {
        println(spnames)
}

v test.v

v fmt -w test.v

v test.v

Expected Behavior

compile ok

Current Behavior

==================
/tmp/v_1000/test_fixed_array.01J1MJ2S78KQ8AEFD7J4VNYMKE.tmp.c:13226: error: cannot convert 'void *' to 'struct string'
...
==================
(Use `v -cg` to print the entire error message)

builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Possible Solution

before v fmt, the generated c code :

Array_fixed_string_2 _const_main__spnames = {_SLIT("abc"), (((voidptr)(0)))}; // fixed array const

after v fmt, the generated c code:

Array_fixed_string_2 _const_main__spnames; // inited later

Additional Information/Context

const spnames = ['abc', (voidptr(0))]!

will create a fixed array const

but , after v fmt,

const spnames = ['abc', (unsafe { nil })]!

will create a variable length array ?

No response

V version

V full version: V 0.4.6 96751ed.4a7c70c

Environment details (OS name and version, etc.)

V full version: V 0.4.6 96751ed.4a7c70c
OS: linux, Ubuntu 22.04.4 LTS
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz

getwd: /home/mars/v/9
vexe: /media/HD/github/lang/v/v
vexe mtime: 2024-06-29 03:29:17

vroot: OK, value: /media/HD/github/lang/v
VMODULES: OK, value: /home/mars/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.34.1
Git vroot status: weekly.2024.26-14-g4a7c70c9 (4 commit(s) behind V master)
.git/config present: true

CC version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5

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.

@kbkpbot kbkpbot added the Bug This tag is applied to issues which reports bugs. label Jun 30, 2024
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant