v
v copied to clipboard
native gen error: unknown return type
V version: 0.2.2 6991a3c OS: Darwin 20.4.0 Darwin Kernel Version 20.4.0: Fri Mar 5 01:14:14 PST 2021; root:xnu-7195.101.1~3/RELEASE_X86_64 x86_64
What did you do? g.v
fn compute(b int) int {
return b * b
}
fn main(){
mut a := []thread int{}
for i in 1 .. 10{
a << go compute(i)
}
r := a.wait()
println(r)
}
v -native -v run g.v
What did you expect to see? no error, and can see native code.
What did you see instead?
------------------------------------------
------ imported modules: ------
['main', 'sync.threads']
-------------------------------
0.079 ms SCAN
3.983 ms PARSE
2.806 ms CHECK
0.005 ms TRANSFORM
0.001 ms Table.complete_interface_check
001000 e8 fb ef ff ff call 0
main.compute:
001005 55 push rbp
001006 48 89 e5 mov rbp, rsp
001009 48 83 ec 20 sub8 rsp,0x20
00100d c7 45 fc 00 00 00 00 mov DWORD [rbp-0x4],0 (Allocate var `b`)
001014 89 7d fc mov DWORD PTR[rbp-0x4],rdi
[/Users/wangzelong/project/v/vlib/v/gen/native/gen.v:349] node: v.ast.Return{
pos: v.token.Position{
len: 12
line_nr: 1
pos: 25
col: 1
last_line: 1
}
comments: []
exprs: [b * b]
types: [7]
}
[/Users/wangzelong/project/v/vlib/v/gen/native/gen.v:350] node.types: [7]
native gen error: unknown return type
@trufae ^^
Threads are not yet supported in the native backend. But the error is clearly misleading and 'de'buggy. So I pushed this PR https://github.com/vlang/v/pull/11253 improving error messages to avoid comptime and thready code to go further and report the error accordingly
I just want to see how to implementation the thread in V, Its underlying layer seems to be pthread; Is his implementation similar to coroutine? Is it similar to golang's GMP model?
Threads are not yet supported in the native backend. But the error is clearly misleading and 'de'buggy. So I pushed this PR #11253 improving error messages to avoid comptime and thready code to go further and report the error accordingly