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

vfmt removes Option types in match statements #21076

Closed
Trakis196 opened this issue Mar 22, 2024 · 1 comment
Closed

vfmt removes Option types in match statements #21076

Trakis196 opened this issue Mar 22, 2024 · 1 comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.

Comments

@Trakis196
Copy link

Trakis196 commented Mar 22, 2024

Describe the bug

If a sum type has an option type as one of its listed types. In a match statement for that sum type, vfmt removes the ? from the type and results in the compiler error of match must be exhaustive.

Reproduction Steps

fn main() {
	f := Foo(?Bar(none))
	match f {
		Baz {}
        	?Bar {}
	}
}

type Foo = ?Bar | Baz
struct Bar {}
struct Baz {}

Expected Behavior

For vfmt to keep the ? in the type name.

Current Behavior

currently vfmt produces from the example code

fn main() {
	f := Foo(?Bar(none))
	match f {
		Baz {}
		Bar {}
	}
}

type Foo = ?Bar | Baz

struct Bar {}

struct Baz {}

and errors when run with Foo has no variant Bar and match must be exhaustive (add match branches for: ?Bar or else {} at the end)

Possible Solution

No response

Additional Information/Context

No response

V version

V 9d4ec7b

Environment details (OS name and version, etc.)

OS: linux, "Arch Linux"
Processor: 12 cpus, 64bit, little endian, AMD Ryzen 5 3600X 6-Core Processor
Git version: git version 2.44.0
Git vroot status: weekly.2023.45.1-870-g9d4ec7b5
.git/config present: true

CC version: cc (GCC) 13.2.1 20230801
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.

@Trakis196 Trakis196 added the Bug This tag is applied to issues which reports bugs. label Mar 22, 2024
@ttytm ttytm added the Unit: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V. label Mar 22, 2024
@felipensp
Copy link
Member

Already fixed by PR #21077

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: vfmt Bugs/feature requests, that are related to the `vfmt`, the formatter for V.
Projects
None yet
Development

No branches or pull requests

3 participants