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 builderr with interfaces that have option fields and embedded structs that implement the interface #19419

Closed
islonely opened this issue Sep 23, 2023 · 0 comments · Fixed by #19434
Labels
Bug This tag is applied to issues which reports bugs. Build V build error on any OS/CPU architecture.

Comments

@islonely
Copy link
Contributor

islonely commented Sep 23, 2023

Describe the bug

An interface that has an option field generates a C error when a struct which embeds another struct that implements the interface tries to access the option field.

Reproduction Steps

import time

interface InterfaceObject {
mut:
	duration ?time.Duration
	update()
}

struct Object {
mut:
	duration ?time.Duration
}

fn (mut obj Object) update() {
	duration := obj.duration or { time.second }
	println(duration)
}

struct FooObject {
	Object
}

fn (mut obj FooObject) update() {
	duration := obj.duration or { time.millisecond * 500 }
	println(duration)
}

fn main() {
	mut object := InterfaceObject(FooObject{})
	println(object)
}

Expected Behavior

Expected code to compile and print the object.

Current Behavior

C error:

C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:519: warning: WINVER redefined
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:7361: warning: implicit declaration of function 'tcc_backtrace'
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15044: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15050: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15056: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15064: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15090: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15090: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15110: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15112: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15112: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15132: warning: assignment from incompatible pointer type
C:/Users/imado/AppData/Local/Temp/v_0/test.16517445185759149149.tmp.c:15313: error: field not found: duration
builder error: 
==================
C error. This should never happen.

Possible Solution

No response

Additional Information/Context

No response

V version

V full version: V 0.4.1 68cbf27.3fab321

Environment details (OS name and version, etc.)


OS: windows, Microsoft Windows 11 Pro v22621 64-bit
Processor: 16 cpus, 64bit, little endian, 

getwd: C:\Users\imado\Documents\cyberian_tiger
vexe: C:\Users\imado\v\v.exe
vexe mtime: 2023-09-23 02:25:12

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

Git version: git version 2.33.1.windows.1
Git vroot status: weekly.2023.38-24-g3fab3213
.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 e90c2620

Important

You can vote for this issue using the 👍 reaction. More votes increase the issue's priority
for developers.

Take into account that only the 👍 reaction counts as a vote.
Only reactions to the issue itself will be counted as votes, not comments.

@islonely islonely added the Bug This tag is applied to issues which reports bugs. label Sep 23, 2023
@ArtemkaKun ArtemkaKun added the Build V build error on any OS/CPU architecture. label Sep 23, 2023
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. Build V build error on any OS/CPU architecture.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants