Skip to content

cgen issue when parsing example with x.json2.decoder2 #25484

@dy-tea

Description

@dy-tea

Describe the bug

Found while working on #25472.

V playground, code also below:
https://play.vlang.io/p/165805379c

Reproduction Steps

import x.json2.decoder2
import time

struct Person {
mut:
	name     string
	age      ?int = 20
	birthday time.Time
	deathday ?time.Time
}

fn main() {
	resp := '{"name": "Bob", "age": 20, "birthday": "${time.now()}"}'
	person := decoder2.decode[Person](resp)!
	println(person)
}

Expected Behavior

Should compile and print person.

Current Behavior

/home/admin/v/vlib/x/json2/decoder2/decode.v:577: error: '{' expected (got ";")
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.12 0f52191

Environment details (OS name and version, etc.)

V full version V 0.4.12 c1d1efb.0f52191
OS linux, "CachyOS"
Processor 16 cpus, 64bit, little endian, AMD Ryzen 7 5700G with Radeon Graphics
Memory 1.82GB/13.55GB
V executable /home/dylan/Repos/v/v
V last modified time 2025-10-11 13:14:28
V home dir OK, value: /home/dylan/Repos/v
VMODULES OK, value: /home/dylan/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/dylan
Git version git version 2.51.0
V git status weekly.2025.40-46-g4fd1aa75
.git/config present true
cc version cc (GCC) 15.2.1 20250813
gcc version gcc (GCC) 15.2.1 20250813
clang version clang version 20.1.8
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (GNU libc) 2.42

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.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.Modules: x.json2Bugs related to *only* x.json2 (the pure V implementation)Option TypeBugs/feature requests, that are related to `?Type`.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions