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 #23693

Open
Eliyaan opened this issue Feb 11, 2025 · 4 comments
Open

C error #23693

Eliyaan opened this issue Feb 11, 2025 · 4 comments
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@Eliyaan
Copy link
Contributor

Eliyaan commented Feb 11, 2025

Describe the bug

The program produces a C error

Reproduction Steps

fn separate_wires(coo_adj_wires [][2]u32, id u64) {
        _ := [][2]u32{len: coo_adj_wires.len, init: coo_adj_wires[index]}
}

fn main() {
        separate_wires([[u32(1), 2]!], 0)
}

Expected Behavior

No C error.

Current Behavior

❯ v run rpdc.v
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/rpdc.01JKVAS7CTJXSHR3AWHCJSFHNR.tmp.c:5708: error: lvalue expected
=================================================================
(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.9

Environment details (OS name and version, etc.)

V full version V 0.4.9 6ac1d08.793487f
OS linux, "Void Linux"
Processor 4 cpus, 64bit, little endian, Intel(R) Pentium(R) Gold 7505 @ 2.00GHz
Memory 5.97GB/23.16GB
V executable /home/nopana/v/v
V last modified time 2025-02-11 18:44:27
V home dir OK, value: /home/nopana/v
VMODULES OK, value: /home/nopana/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/nopana/projects/notOnlyNots
Git version git version 2.47.1
V git status weekly.2025.04-76-g793487fd
.git/config present true
cc version cc (GCC) 13.2.0
gcc version gcc (GCC) 13.2.0
clang version N/A
tcc version tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
tcc git status thirdparty-linux-amd64 0134e9b9
emcc version N/A
glibc version ldd (GNU libc) 2.39

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 Feb 11, 2025
Copy link

Connected to Huly®: V_0.6-22113

@felipensp felipensp added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label Feb 11, 2025
@JalonSolov
Copy link
Contributor

If you compile with -g, it tells you the error is on the last line of the example, the closing } for main.

@JalonSolov JalonSolov added the Status: Confirmed This bug has been confirmed to be valid by a contributor. label Feb 11, 2025
@jorgeluismireles
Copy link

index is a typo in init: coo_adj_wires[index], so this works:

fn separate_wires(coo_adj_wires [][2]u32, id u64) {
        _ := [][2]u32{len: coo_adj_wires.len, init: coo_adj_wires[id]}
}

and when we type not index but other typo for instance inde a V error is thrown:

    1 | fn separate_wires(coo_adj_wires [][2]u32, id u64) {
    2 |         _ := [][2]u32{len: coo_adj_wires.len, init: coo_adj_wires[inde]}
      |                                                                   ~~~~
    3 | }
    4 |

@Eliyaan
Copy link
Contributor Author

Eliyaan commented Feb 11, 2025

it is not a typo, index is a special variable that holds the index of the current element while creating the array.
example:

a := []int{len:3, init:index} // [0, 1, 2]

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. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

No branches or pull requests

4 participants