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

undefined values for an option multireturning function, that executes return none, instead of a checker error #21117

Closed
spytheman opened this issue Mar 27, 2024 · 1 comment · Fixed by #21106
Labels
Bug This tag is applied to issues which reports bugs. Option Type Bugs/feature requests, that are related to `?Type`. Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@spytheman
Copy link
Member

spytheman commented Mar 27, 2024

V doctor:

V full version: V 0.4.5 e6b43a1.8511731
OS: linux, Ubuntu 20.04.6 LTS
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz

getwd: /space/v/oo
vexe: /space/v/oo/v
vexe mtime: 2024-03-27 13:36:18

vroot: OK, value: /space/v/oo
VMODULES: OK, value: /home/delian/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.42.0
Git vroot status: weekly.2024.13-27-g7e0e2aaa
.git/config present: true

CC version: cc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5

What did you do?
v -g -o vdbg cmd/v && vdbg x.v

fn f() ?(int, string) {
	// return 42, 'the answer'
	return none
}

x, y := f()
dump(x)
dump(y)

What did you expect to see?

A checker error, telling me that x,y := f() should be if x, y := f() { or x, y := f()? instead .

What did you see instead?

[x.v:7] x: 0
[x.v:8] y: 

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 Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: Checker Bugs/feature requests, that are related to the type checker. Option Type Bugs/feature requests, that are related to `?Type`. labels Mar 27, 2024
@ttytm
Copy link
Member

ttytm commented Mar 27, 2024

Should be solved with the referenced PR.

error: f() returns `?(int, string)`, so it should have either an `or {}` block, or `?` at the end
    4 | }
    5 | 
    6 | x, y := f()
      |         ~~~
    7 | dump(x)
    8 | dump(y)

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. Option Type Bugs/feature requests, that are related to `?Type`. Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants