We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
thread.wait() should be able to return any type a function can return. But results, options, and multi-returns are not allowed types for threads.
thread.wait()
struct Foo { mut: tx thread !int ty thread ?int tz thread (int, int) } fn Foo.new() Foo { mut foo := Foo{ tx: spawn x(-1) ty: spawn y(-1) tz: spawn z(-1) } return foo } fn (mut foo Foo) bar() { foo.tx.wait() or { // error was returned 0 } foo.ty.wait() or { // none was returned 0 } a_num, b_num := foo.tz.wait() } fn x(x int) !int { if x < 0 { return error('error') } return x } fn y(y int) ?int { if y < 0 { return none } return y } fn z(z int) (int, int) { return (z, z) } fn main() { mut foo := Foo.new() // do something else with foo while foo // continues something() on another thread foo.bar() }
Expected code to compile and run.
Unexpected token error is generated.
C:/Users/imado/Documents/test.v:3:12: error: unexpected token `!`, expecting name 1 | struct Foo { 2 | mut: 3 | tx thread !int | ^ 4 | ty thread ?int 5 | tz thread (int, int)
No response
V 0.4.1 639f128
V full version: V 0.4.1 639f128 OS: windows, Microsoft Windows 11 Pro v22621 64-bit Processor: 16 cpus, 64bit, little endian,
getwd: C:\Users\imado\Documents\test vexe: C:\Users\imado\v\v.exe vexe mtime: 2023-09-05 17:00:49
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: 0.4.1-10-g639f128c .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
The text was updated successfully, but these errors were encountered:
parser: implement thread returns result and multi_returns(fix vlang#1…
a0f843a
…9281)
136193a
No branches or pull requests
Describe the bug
thread.wait()
should be able to return any type a function can return. But results, options, and multi-returns are not allowed types for threads.Reproduction Steps
Expected Behavior
Expected code to compile and run.
Current Behavior
Unexpected token error is generated.
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.1 639f128
Environment details (OS name and version, etc.)
V full version: V 0.4.1 639f128
OS: windows, Microsoft Windows 11 Pro v22621 64-bit
Processor: 16 cpus, 64bit, little endian,
getwd: C:\Users\imado\Documents\test
vexe: C:\Users\imado\v\v.exe
vexe mtime: 2023-09-05 17:00:49
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: 0.4.1-10-g639f128c
.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
The text was updated successfully, but these errors were encountered: