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 (fixed arrays) #23277

Closed
Eliyaan opened this issue Dec 26, 2024 · 1 comment · Fixed by #23279
Closed

C error (fixed arrays) #23277

Eliyaan opened this issue Dec 26, 2024 · 1 comment · Fixed by #23279
Assignees
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 Dec 26, 2024

Describe the bug

The code produces a c error from a pure V code.

Reproduction Steps

Using v run :

fn main() {
}

fn  get_chunkmap_at_coords(mapp []Chunk) [chunk_size][chunk_size]u64 {
                                return mapp[0].id_map
}

const chunk_size = 100

struct Chunk {
        id_map [chunk_size][chunk_size]u64 // [x][y] x++=east y++=south
}

Expected Behavior

To not have a C error

Current Behavior

❯ v run .
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/notOnlyNots.01JG1XQ3YHDDSTVPJGA5GBTEVT.tmp.c:1047: error: ';' expected (got "Array_fixed_u64_0")
=================================================================
(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 full version: V 0.4.9 6ac1d08.f8c9edd

Environment details (OS name and version, etc.)

OS: linux, "Void Linux"

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.

Huly®: V_0.6-21711

@Eliyaan Eliyaan added the Bug This tag is applied to issues which reports bugs. label Dec 26, 2024
@felipensp felipensp added 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. labels Dec 26, 2024
@felipensp
Copy link
Member

Moving your const declaration makes it works.

fn main() {
}
const chunk_size = 100

fn  get_chunkmap_at_coords(mapp []Chunk) [chunk_size][chunk_size]u64 {
                                return mapp[0].id_map
}

struct Chunk {
        id_map [chunk_size][chunk_size]u64 // [x][y] x++=east y++=south
}

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

Successfully merging a pull request may close this issue.

2 participants