Skip to content

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

@4lxprime

Description

@4lxprime

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.

Metadata

Metadata

Assignees

Labels

Generics[T]Bugs/feature requests, that are related to the V generics.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions