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

c compiler error on interface method with type alias #22326

Closed
daansystems opened this issue Sep 27, 2024 · 1 comment · Fixed by #22331
Closed

c compiler error on interface method with type alias #22326

daansystems opened this issue Sep 27, 2024 · 1 comment · Fixed by #22331
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@daansystems
Copy link

daansystems commented Sep 27, 2024

I think this is related to the fix in #22320
It seems to cause a new issue:

V doctor:

V full version: V 0.4.7 18eee34.c7bdc0a
OS: windows, Microsoft Windows 11 Pro v22631 64-bit
Processor: 24 cpus, 64bit, little endian, 

getwd: D:\vbug
vexe: C:\v\v.exe
vexe mtime: 2024-09-27 05:14:05

vroot: OK, value: C:\v
VMODULES: OK, value: C:\Users\info\.vmodules
VTMP: OK, value: C:\Users\info\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.2
Git vroot status: weekly.2024.39-29-gc7bdc0a7-dirty
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,

operable program or batch file.


thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

What did you do?
./v -g -o vdbg cmd/v && ./vdbg src\main.v

module main

pub type Mat4 = [16]f32

pub fn (a Mat4) * (b Mat4) Mat4 {
	mut res := Mat4{}
	for i := 0; i < 4; i++ {
		for j := 0; j < 4; j++ {
			res[j * 4 + i] = 0
			for k := 0; k < 4; k++ {
				res[j * 4 + i] += a[k * 4 + i] * b[j * 4 + k]
			}
		}
	}
	return res
}

interface IGameObject {
	world_transform() Mat4
	parent	?&IGameObject
	transform Mat4
}

struct GameObject implements IGameObject {
mut:
	transform Mat4
	parent    ?&IGameObject
}

fn (gameobject GameObject) world_transform() Mat4 {
	if mut p := gameobject.parent {
		return p.world_transform() * gameobject.transform
	}
	return gameobject.transform
}

fn main() {}

What did you expect to see?

no c compiler error

What did you see instead?

================== C compilation error (from tcc): ==============
cc: C:/Users/info/AppData/Local/Temp/v_0/main.01J8RZD1SRCTWSMV5JBM3H1DCN.tmp.c:7097: warning: implicit declaration of function 'tcc_backtrace'
cc: C:/Users/info/AppData/Local/Temp/v_0/main.01J8RZD1SRCTWSMV5JBM3H1DCN.tmp.c:13583: error: cannot convert 'struct _v_Array_fixed_f32_16' to 'float *'
... (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 .

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.

@esquerbatua
Copy link
Contributor

Seems that #22320 it's an improve but not fixes that:

/tmp/v_1000/break.tmp.c:13441: error: cannot convert 'struct _v_Array_fixed_f32_16' to 'float *'
builder error: 
==================
C error found. It should never happen, when compiling pure V code.

@esquerbatua esquerbatua added Unit: Checker Bugs/feature requests, that are related to the type checker. Bug This tag is applied to issues which reports bugs. labels Sep 27, 2024
@felipensp felipensp added Unit: cgen Bugs/feature requests, that are related to the default C generating backend. and removed Unit: Checker Bugs/feature requests, that are related to the type checker. labels Sep 27, 2024
@felipensp felipensp self-assigned this Sep 27, 2024
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. 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.

3 participants