Skip to content

cgen: error: '{' expected (got ";") #23501

Description

@koplenov
V version: V 0.4.9 496451e, press to see full `v doctor` output
V full version V 0.4.9 4fcd94a.496451e
OS windows, Њ ©Єа®б®дв Windows 10 Pro 19045 64-а §ап¤­ п
Processor 28 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz
Memory 16.35GB/31.86GB
V executable C:\Dev\Progs\v\v.exe
V last modified time 2025-01-17 20:10:01
V home dir OK, value: C:\Dev\Progs\v
VMODULES OK, value: C:\Users\koplenov.vmodules
VTMP OK, value: C:\Users\koplenov\AppData\Local\Temp\v_0
Current working dir OK, value: C:\Dev\Zone\mam_v\treevee\src\ast\repro2
Git version git version 2.42.0.windows.2
V git status weekly.2025.1-72-g496451ec
.git/config present true
cc version N/A
gcc version gcc (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r4) 13.2.0
clang version clang version 18.1.2
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status thirdparty-windows-amd64 b425ac82
emcc version N/A
glibc version N/A

What did you do?
./v -g -o vdbg cmd/v && ./vdbg .\main.v && C:\Dev\Zone\mam_v\treevee\src\ast\repro2\main.exe

module main

pub struct Tree {}
pub fn (tree &Tree) str() string {
	return ""
}

pub struct TreeTwo {
	Tree
}
pub fn TreeTwo.from_string(tree_string string) !&TreeTwo{
	return &TreeTwo{}
}

fn main(){
	tree := TreeTwo.from_string("") or { panic(err) }
	println(tree.str())
}

What did you see?

================== C compilation error (from tcc): ==============
cc: C:/Users/koplenov/AppData/Local/Temp/v_0/main.01JHTY7RB3A0Y45GT5G6B5CVZ2.tmp.c:1727: warning: implicit declaration of function 'string_repeat'
cc: C:/Users/koplenov/AppData/Local/Temp/v_0/main.01JHTY7RB3A0Y45GT5G6B5CVZ2.tmp.c:1727: error: '{' expected (got ";")
... (the original output was 3 lines long, and was truncated to 2 lines)
=================================================================
(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?

Successful compilation

But this compiles:

module main

pub struct Tree {}
pub fn (tree &Tree) my_str() string {
	return ""
}

pub struct TreeTwo {
	Tree
}
pub fn TreeTwo.from_string(tree_string string) !&TreeTwo{
	return &TreeTwo{}
}

fn main(){
	tree := TreeTwo.from_string("") or { panic(err) }
	println(tree.my_str())
}

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.Unit: cgenBugs/feature requests, that are related to the default C generating backend.Unit: markusedBugs/feature requests, that are related to the -skip-unused.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions