Skip to content

C error: json2.decoder2 array of sumtypes one empty struct #25263

@jorgeluismireles

Description

@jorgeluismireles
V version: V 0.4.11 847c15e, press to see full `v doctor` output
V full version V 0.4.11 e96355a.847c15e
OS linux, Ubuntu 22.04.5 LTS
Processor 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-4150 CPU @ 3.50GHz
Memory 0.51GB/3.7GB
V executable /home/jorge/v/v
V last modified time 2025-09-08 18:40:30
V home dir OK, value: /home/jorge/v
VMODULES OK, value: /home/jorge/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/jorge/bugs/250908
Git version git version 2.34.1
V git status weekly.2025.16-741-g847c15e5-dirty
.git/config present true
cc version cc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
gcc version gcc (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0
clang version Ubuntu clang version 14.0.0-1ubuntu1.1
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.5 ()
glibc version ldd (Ubuntu GLIBC 2.35-0ubuntu3.10) 2.35

What did you do?
./v -g -o vdbg cmd/v && ./vdbg 250908-c.v && 250908-c

import x.json2.decoder2

struct Empty { 
	
}
type Elem = int | Empty

fn main() {
	text := '[ 0, { }, 2 ]'
	e := decoder2.decode[[]Elem](text) or {
		dump(err)
		return
	}
	dump(e)
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/250908-c.01K4NK3S5452FS91A6W19EREBC.tmp.c:10323: error: ';' expected (got "}")
=================================================================
(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.
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 .

What did you expect to see?

A decoded array of sumtypes

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

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions