Skip to content

Passing a struct with an enum array with json.encode produces a compile bug #15093

@Crawron

Description

@Crawron

V version: V 0.3.0 0d6d6f7.ac7e809
OS: linux, "EndeavourOS Linux"

What did you do?
Tried to encode a struct with an enum array with json.encode. Standalone example

import json

enum TestEnum {
	one = 1
}

struct TestStruct {
	test []TestEnum
}

fn main () {
	println(json.encode(TestStruct{test: [TestEnum.one]}))
}

Ran with v -cg run .

What did you expect to see?

{"test":[1]}

What did you see instead?

/usr/lib64/crt1.o: error: Invalid relocation entry [15] '.rela.debug_info' @ 000004f5
tcc: error: file 'crt1.o' not found
/tmp/v_1000/something.8468612194315468929.tmp.c:2209: error: '_option_main__TestEnum' undeclared
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.Fixed in x.json2A JSON related issue, that is fixed in `x.json2` module.Modules: JSONBugs/feature requests, that are related to `json` and `x.json2` modules.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions