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

V formatter panics on code generated by C2V #20730

Closed
odiroot opened this issue Feb 4, 2024 · 0 comments · Fixed by #20732
Closed

V formatter panics on code generated by C2V #20730

odiroot opened this issue Feb 4, 2024 · 0 comments · Fixed by #20732
Labels
Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).

Comments

@odiroot
Copy link

odiroot commented Feb 4, 2024

V doctor:

V full version: V 0.4.4 ac2dcc2.8609ea1
OS: linux, "EndeavourOS Linux"
Processor: 12 cpus, 64bit, little endian, AMD Ryzen 5 PRO 4650U with Radeon Graphics

getwd: /home/odi/Repos/vclap-experiment/src/vnkxcb
vexe: /home/odi/Repos/vlang/v
vexe mtime: 2024-02-04 18:33:35

vroot: OK, value: /home/odi/Repos/vlang
VMODULES: OK, value: /home/odi/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.0
Git vroot status: 0.4.4-185-g8609ea19
.git/config present: true

CC version: cc (GCC) 13.2.1 20230801
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

What did you do?
v fmt vnkxcb_poc.v

(Part of a bigger example)

@[translated]
module vnkxcb

type Nk_size = u32

union Nk_handle {
	ptr voidptr
	id int
}

enum Nk_plugin_alloc {
	nk_tree_node
	nk_tree_tab
}

type Nk_plugin_alloc = fn (Nk_handle, voidptr, Nk_size) voidptr

What did you expect to see?

V formatter should either sucessfully format the source file or show the errors.

What did you see instead?

V panic: as cast: cannot cast `v.ast.Enum` to `v.ast.FnType`
v hash: 8609ea1
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:19192: at _v_panic: Backtrace
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:19688: by __as_cast
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:50855: by v__fmt__Fmt_fn_type_decl
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:50820: by v__fmt__Fmt_type_decl
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:49658: by v__fmt__Fmt_stmt
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:49560: by v__fmt__Fmt_stmts
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:49072: by v__fmt__fmt
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:2357: by main__FormatOptions_format_file
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:2241: by main__main
/tmp/v_1000/vfmt.01HNTPKG4Q8RRW4WWPGHRX56EX.tmp.c:3122: by main

Internal vfmt error while formatting file: vnkxcb_poc.v.
Encountered a total of: 1 errors.

Note
The V source file was generated using c2v wrapper on nuklear.h library.
The full translated header is here. I had to make a few small manual fixes (e.g. changing some spurious * into &).

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.

@felipensp felipensp added the Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones). label Feb 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants