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

C Error: Generic Result/Option Function Return Fixed Array #20465

Closed
heyimtcn opened this issue Jan 10, 2024 · 0 comments · Fixed by #20479
Closed

C Error: Generic Result/Option Function Return Fixed Array #20465

heyimtcn opened this issue Jan 10, 2024 · 0 comments · Fixed by #20479
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. Option Type Bugs/feature requests, that are related to `?Type`. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@heyimtcn
Copy link

heyimtcn commented Jan 10, 2024

Describe the bug

Calling a generic function T that returns T in an Option or Result with T being a fixed array will cause this error to happen.

Reproduction Steps

fn example[T]() ?T {
	return T{}
}

fn main() {
	example[[1]int]()
}

Expected Behavior

The array T to be returned.

Current Behavior

It created a C error as follows:

/tmp/v_60000/code.10172036010122743983.tmp.c:1881: warning: type defaults to int
/tmp/v_60000/code.10172036010122743983.tmp.c:1881: error: ';' expected (got "main__example_T_Array_fixed_int_1")

Possible Solution

It appears the issue lies in the automatically generated function name.

Additional Information/Context

The element type and size of T don't matter.

This bug has been found and only been tested on V Playground.

V version

V 0.4.4 28e810d

Environment details (OS name and version, etc.)

V full version: V 0.4.4 28e810d
OS: linux, Debian GNU/Linux 11 (bullseye) (VM)
Processor: 1 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz

getwd: /home/admin/playground
vexe: /home/admin/v/v
vexe mtime: 2024-01-10 11:15:03

vroot: OK, value: /home/admin/v
VMODULES: OK, value: .vmodules
VTMP: OK, value: /tmp/v_0

Git version: git version 2.30.2
Git vroot status: Error: fatal: detected dubious ownership in repository at '/home/admin/v'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v
.git/config present: true

CC version: cc (Debian 10.2.1-6) 10.2.1 20210110
thirdparty/tcc status: Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v/thirdparty/tcc
 Error: fatal: detected dubious ownership in repository at '/home/admin/v/thirdparty/tcc'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/admin/v/thirdparty/tcc

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.

@heyimtcn heyimtcn added the Bug This tag is applied to issues which reports bugs. label Jan 10, 2024
@felipensp felipensp added Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Generics[T] Bugs/feature requests, that are related to the V generics. Option Type Bugs/feature requests, that are related to `?Type`. labels Jan 10, 2024
@felipensp felipensp self-assigned this Jan 10, 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. Generics[T] Bugs/feature requests, that are related to the V generics. Option Type Bugs/feature requests, that are related to `?Type`. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants