Skip to content

build error json.encode() optional field. #16462

@ghost

Description

V version: 0.3.2 ae816b1
OS: ArchLinux

What did you do?

import json

struct Foo{
	name string
	num  ?int
}

fn main(){
	f := Foo{}
	dump(json.encode(f))
}

What did you expect to see?
No error.
Ideally, the following results.
{"name":""} or {"name":"","num":null}

What did you see instead?

==================
/tmp/v_1000/bug.330116750381110337.tmp.c:2155: error: '_result__option_int' undeclared
...
==================

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.Option TypeBugs/feature requests, that are related to `?Type`.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions