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

Compilation error when using omitempty with params struct #20839

Closed
AoJ opened this issue Feb 15, 2024 · 0 comments · Fixed by #20851
Closed

Compilation error when using omitempty with params struct #20839

AoJ opened this issue Feb 15, 2024 · 0 comments · Fixed by #20851

Comments

@AoJ
Copy link

AoJ commented Feb 15, 2024

V doctor:

V full version: V 0.4.4 c9933da.4f742ad
OS: macos, macOS, 14.3.1, 23D60
Processor: 8 cpus, 64bit, little endian, Apple M2

getwd: /tmp/v_bug
vexe: /opt/homebrew/Cellar/vlang/0.4.4/libexec/v
vexe mtime: 2024-02-15 12:11:23

vroot: OK, value: /opt/homebrew/Cellar/vlang/0.4.4/libexec
VMODULES: OK, value: /tmp/v/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.39.3 (Apple Git-145)
Git vroot status: weekly.2024.07-21-g4f742ad1
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.1.0.2.5)
thirdparty/tcc status: thirdparty-macos-arm64 5c1d002f

Note: the same problem exists on Linux.

What did you do?
v -g -o vdbg cmd/v && vdbg src/bug.v

import json


@[params]
struct SomeParams {
    name string
    sub_struct struct {
        id string
    } @[omitempty]
}


pub fn some_fn(p SomeParams) string {
    return json.encode(p)
}

What did you expect to see?

Compile it without a error "C error"

What did you see instead?

==================
/tmp/v_501/bug.01HPPAW2HJG5KEPPE3SVP17KNX.tmp.c:2247:53: error: expected expression
        if (!main___VAnonStruct1_struct_eq(val.sub_struct, {.id = (string){.str=(byteptr)"", .is_lit=1},}))
                                                           ^
1 error generated.
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant