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 - multiple returns values and fixed arrays #22062

Closed
Eliyaan opened this issue Aug 16, 2024 · 0 comments · Fixed by #22069
Closed

C error - multiple returns values and fixed arrays #22062

Eliyaan opened this issue Aug 16, 2024 · 0 comments · Fixed by #22069
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@Eliyaan
Copy link
Contributor

Eliyaan commented Aug 16, 2024

Describe the bug

When returning multiple values, if one of those is a fixed size array, it seems to be the cause of a C error.

Reproduction Steps

fn double() (bool, [4]i16) {
        return true, [4]i16{}
}

fn foo() {
        _, b := double()
        for i in b {
        }
}

with v bug.v

Expected Behavior

No C error.

Current Behavior

❯ v bug.v
bug.v:7:6: warning: unused variable: `i`
    5 | fn foo() {
    6 |     _, b := double()
    7 |     for i in b {
      |         ^
    8 |     }
    9 | }
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/bug.01J5EG61QWPZ7RVQCYVP6FH9BK.tmp.c:13289: error: invalid operand types for binary operation
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error:
==================
C error found. It should never happen, when compiling pure V code.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.7 294f7e4.8210593

Environment details (OS name and version, etc.)

OS: linux, Linux version 6.7.11-200.fc39.x86_64 (mockbuild@bdb8d24f206645e2bda44c1cf867612d) (gcc (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7), GNU ld version 2.40-14.fc39) #1 SMP PREEMPT_DYNAMIC Wed Mar 27 16:50:39 UTC 2024

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.

@Eliyaan Eliyaan added the Bug This tag is applied to issues which reports bugs. label Aug 16, 2024
@spytheman spytheman added Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. labels Aug 16, 2024
@felipensp felipensp self-assigned this Aug 17, 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. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants