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

builder error: calling generic static type method from a module #21476

Open
4lxprime opened this issue May 8, 2024 · 0 comments
Open

builder error: calling generic static type method from a module #21476

4lxprime opened this issue May 8, 2024 · 0 comments
Labels
Generics[T] Bugs/feature requests, that are related to the V generics. 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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@4lxprime
Copy link

4lxprime commented May 8, 2024

Environment details

V full version: V 0.4.5 4cb5949
OS: windows, Microsoft Windows 11 Home v22631 64-bit
Processor: 12 cpus, 64bit, little endian, 

getwd: C:\Users\me\Documents\Code\Test\v_error
vexe: C:\v\v.exe
vexe mtime: 2024-05-04 13:10:47

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

Git version: git version 2.44.0.windows.1
Git vroot status: Error: fatal: not a git repository (or any of the parent directories): .git
.git/config present: false

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

operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 b99a453d

What did you do?
command: v -cg src
files:
src/main.v:

module main

import foo { Foo }

struct Bar {}

fn main() {
	// note: will succeed with foo.Foo
	f := Foo.new[Bar](Bar{})

	println(typeof(f).name)
}

src/foo.v:

module foo

pub struct Foo[T] {}

pub fn Foo.new[T](embed T) &Foo[T] {
	return &Foo[T]{}
}

What did you expect to see?

should compile and output: &foo.Foo[Bar]

What did you see instead?

src/main.v:3:8: warning: module 'foo' is imported but never used
    1 | module main
    2 | 
    3 | import foo { Foo }
      |        ~~~
    4 | 
    5 | struct Bar {}
C:/Users/me/AppData/Local/Temp/v_0/app.01HXCDGE2JE6BQP7Q7MQX1C279.tmp.c:510: warning: WINVER redefined
C:/Users/me/AppData/Local/Temp/v_0/app.01HXCDGE2JE6BQP7Q7MQX1C279.tmp.c:6916: warning: implicit declaration of function 'tcc_backtrace'
C:/Users/me/AppData/Local/Temp/v_0/app.01HXCDGE2JE6BQP7Q7MQX1C279.tmp.c:13184: warning: implicit declaration of function 'foo__Foo__static__new_T_main__Bar'
C:/Users/me/AppData/Local/Temp/v_0/app.01HXCDGE2JE6BQP7Q7MQX1C279.tmp.c:13184: warning: assignment makes pointer from integer without a cast
C:/Users/me/AppData/Local/Temp/v_0/app.01HXCDGE2JE6BQP7Q7MQX1C279.tmp.c:13184: warning: cast between pointer and integer of different size
tcc: error: undefined symbol 'foo__Foo__static__new_T_main__Bar'
builder 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.

@spytheman spytheman added Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Status: Confirmed This bug has been confirmed to be valid by a contributor. labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Generics[T] Bugs/feature requests, that are related to the V generics. 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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

No branches or pull requests

2 participants