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 Error when running mawfig's Generics example #18007

Open
damywise opened this issue Apr 21, 2023 · 1 comment · May be fixed by #18011
Open

C Error when running mawfig's Generics example #18007

damywise opened this issue Apr 21, 2023 · 1 comment · May be fixed by #18011
Labels
Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@damywise
Copy link

damywise commented Apr 21, 2023

Describe the bug

Code 1: https://vosca.dev/p/122810bb42
Code 2: https://vosca.dev/p/71d8a80124

struct Wrapped[T] {
	value T
}

fn (w Wrapped[T]) double() Wrapped[T] {
	return Wrapped[T]{w.value * 2}
}

fn make_wrapped[T](value T) Wrapped[T] {
	return Wrapped[T]{value}
}

fn main() {
	println(make_wrapped('str'))
}
struct MyStruct<T> {
    val T
}

struct Foo {
    x int
}

struct MyStruct_T_main__Foo {
    bla string
}

fn main() {
    x := MyStruct<Foo> { Foo { 0 } }
    y := MyStruct_T_main__Foo { "" }
    println(x)
    println(y)
}

Expected Behavior

No C error

Current Behavior

Output:

/tmp/v_60000/../../../../../../box/code.v:6: error: invalid operand types for binary operation
/tmp/v_60000/../../../../../../box/code.v:6: error: invalid aggregate type for register load
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Exited with error status 1
/tmp/v_0/code.tmp.c:1512: error: field not found: val
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Reproduction Steps

open the code url

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.3.3 fc4c431.adcd16b

Environment details (OS name and version, etc.)

V full version: V 0.3.3 fc4c431.adcd16b
OS: linux, Ubuntu 22.04.2 LTS
Processor: 2 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz

getwd: /home/pmakhnev/playground
vexe: /home/pmakhnev/v/v
vexe mtime: 2023-04-18 15:52:07

vroot: OK, value: /home/pmakhnev/v
VMODULES: OK, value: /root/.vmodules
VTMP: OK, value: /tmp/v_0

Git version: git version 2.34.1
Git vroot status: weekly.2023.15-38-gadcd16b1
.git/config present: true

CC version: cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3
@damywise damywise added the Bug This tag is applied to issues which reports bugs. label Apr 21, 2023
@damywise damywise changed the title C Error when running mawfig example C Error when running mawfig Generics example Apr 21, 2023
@damywise damywise changed the title C Error when running mawfig Generics example C Error when running mawfig's Generics example Apr 21, 2023
@felipensp
Copy link
Member

I've added a PR to validate the string operation for the first case. In the last one the we have a name collision, causing the problem.

@felipensp felipensp added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Apr 21, 2023
@felipensp felipensp added the Generics[T] Bugs/feature requests, that are related to the V generics. label Jul 24, 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. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Checker Bugs/feature requests, that are related to the type checker.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants