Skip to content

invalid c generated for my complex arrays.fold call #26498

@dy-tea

Description

@dy-tea

Describe the bug

Code snippet that seems to cause problems is in zulip/bot.v lines 66:88

Didn't look into exactly what is causing the cgen issue, maybe a smaller repro can be made.

		arrays.fold(r.events, []Event{}, fn (acc []Event, a json2.Any) []Event {
			typ := json2.decode[ResponseStub](a.str()) or { ResponseStub {.unknown} }.etyp
			res := match typ {
				.message {
					Event(json2.decode[MessageEvent](a.str()) or {
						panic(err)
					})
				}
				.reaction {
					Event(json2.decode[ReactionEvent](a.str()) or {
						panic(err)
					})
				}
				else {
					eprintln('UNSUPPORTED EVENT TYPE')
					none
				}
			}
			if r := res {
				return arrays.append(acc, [r])
			}
			return acc
		})
❯ v run echobot.v
================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/echobot.01KGDYAXWWYWK4TXYP1JTFQD4A.tmp.c:6504: warning: type defaults to int
cc: /tmp/v_1000/echobot.01KGDYAXWWYWK4TXYP1JTFQD4A.tmp.c:6504: error: ';' expected (got "*")
=================================================================
Try passing `-g` when compiling, to see a .v file:line information, that correlates more with the C error.
(Alternatively, pass `-show-c-output`, to print the full C error message).
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 .

Reproduction Steps

See: https://github.com/dy-tea/vulip

git clone https://github.com/dy-tea/vulip
cd vulip
v run echobot.v

Expected Behavior

Should compile, or maybe not; I am not entirely sure what I was doing here.

Current Behavior

.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.5.0 50a7d53

Environment details (OS name and version, etc.)

V full version V 0.5.0 a965a39.50a7d53
OS linux, "CachyOS"
Processor 12 cpus, 64bit, little endian, 13th Gen Intel(R) Core(TM) i5-1335U
Memory 4.19GB/15.31GB
V executable /home/dylan/Repos/v/v
V last modified time 2026-01-28 17:56:57
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.52.0
V git status weekly.2026.02-182-g50a7d536
.git/config present true
cc version cc (GCC) 15.2.1 20260103
gcc version gcc (GCC) 15.2.1 20260103
clang version clang version 21.1.6
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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions