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

(only when optional) type checking fails, when the type is an array of a sumtype #19917

Closed
Ddiidev opened this issue Nov 17, 2023 · 0 comments · Fixed by #19919
Closed

(only when optional) type checking fails, when the type is an array of a sumtype #19917

Ddiidev opened this issue Nov 17, 2023 · 0 comments · Fixed by #19919
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@Ddiidev
Copy link
Contributor

Ddiidev commented Nov 17, 2023

Describe the bug

Code: https://vosca.dev/p/eaa0c6455a

pub type TType = string | []int

pub fn teste() ?TType {
	return TType([1,2])
}

x := teste()

if x is []int {
	dump(x)
}

Reproduction Steps

https://vosca.dev/p/eaa0c6455a

Expected Behavior

[code.v:10] x: Option(TType([1, 2]))

Current Behavior

Output:

/tmp/v_60000/../../../../../../box/code.v:10: error: field not found: _Array_int
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Exited with error status 1

Possible Solution

No response

Additional Information/Context

If the variable is not optional, the check works perfectly.

try changing line 10 to as it is below and it will work...
x := teste()?

V version

V 0.4.3 c3cf9ee

Environment details (OS name and version, etc.)

V full version: V 0.4.3 c3cf9ee.b347f54
OS: linux, Ubuntu 22.04.2 LTS
Processor: 2 cpus, 64bit, little endian, Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz

getwd: /home/pmakhnev/playground
vexe: /home/pmakhnev/v/v
vexe mtime: 2023-11-17 12:00:12

vroot: OK, value: /home/pmakhnev/v
VMODULES: OK, value: /root/.vmodules
VTMP: OK, value: /tmp/v_0

Git version: git version 2.34.1
Git vroot status: weekly.2023.45.1-64-gb347f546
.git/config present: true

CC version: cc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

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.

@Ddiidev Ddiidev added the Bug This tag is applied to issues which reports bugs. label Nov 17, 2023
@felipensp felipensp self-assigned this Nov 17, 2023
@felipensp felipensp added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label Nov 17, 2023
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. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants