Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printing reference interface gives c error: expected struct or union but not 'struct main__IGameObject *' #23406

Closed
daansystems opened this issue Jan 8, 2025 · 0 comments · Fixed by #23409
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Option Type Bugs/feature requests, that are related to `?Type`. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@daansystems
Copy link

daansystems commented Jan 8, 2025

V version: V 0.4.9 9fc8352, press to see full `v doctor` output
V full version V 0.4.9 5c65e58.9fc8352
OS windows, Microsoft Windows 11 Pro 26100 64-bit
Processor 24 cpus, 64bit, little endian, AMD Ryzen 9 3900X 12-Core Processor
Memory 13.38GB/31.9GB
V executable C:\v\v.exe
V last modified time 2025-01-08 08:35:54
V home dir OK, value: C:\v
VMODULES OK, value: C:\Users\info.vmodules
VTMP OK, value: C:\Users\info\AppData\Local\Temp\v_0
Current working dir OK, value: D:\vbug2
Git version git version 2.42.0.windows.2
V git status weekly.2025.1-12-g9fc83526-dirty
.git/config present true
cc version N/A
gcc version N/A
clang version clang version 17.0.1
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 && D:\vbug2\main.exe

module main

interface IGameObject {
mut:
	name     string
	parent   ?&IGameObject
	children []&IGameObject
	add_child(mut o IGameObject)
	advance()
}

@[heap]
struct GameObject implements IGameObject {
mut:
	name     string
	parent   ?&IGameObject
	children []&IGameObject
}

fn (mut gameobject GameObject) add_child(mut o IGameObject) {
	o.parent = &gameobject
	gameobject.children << o
}

fn (mut gameobject GameObject) advance() {
	if gameobject.parent != none {
		eprintln('parent:  ${gameobject.parent.name} ')
	}
	for mut child in gameobject.children {
		child.advance()
	}
}

fn main() {
	mut v1 := &GameObject{
		name: 'v1'
	}
	mut v2 := &GameObject{
		name: 'v2'
	}
	v1.add_child(mut v2)
	v1.advance()
}

What did you see?

================== C compilation error (from tcc): ==============
cc: C:/Users/info/AppData/Local/Temp/v_0/main.01JH2HA9HEFH6AV8DAFFRW06R8.tmp.c:4050: warning: implicit declaration of function 'tcc_backtrace'
cc: C:/Users/info/AppData/Local/Temp/v_0/main.01JH2HA9HEFH6AV8DAFFRW06R8.tmp.c:6623: error: expected struct or union but not 'struct main__IGameObject *'
... (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?

no c error

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.

@felipensp felipensp self-assigned this Jan 8, 2025
@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Option Type Bugs/feature requests, that are related to `?Type`. labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Option Type Bugs/feature requests, that are related to `?Type`. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants