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

bool alias cannot be used in if statement #17818

Closed
qtc-de opened this issue Mar 29, 2023 · 0 comments · Fixed by #17821
Closed

bool alias cannot be used in if statement #17818

qtc-de opened this issue Mar 29, 2023 · 0 comments · Fixed by #17821
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@qtc-de
Copy link
Contributor

qtc-de commented Mar 29, 2023

Describe the bug

When defining an alias type for bool it cannot be used within if statements. I have no idea of language design and I'm totally fine with this issue being closed when it does not make sense. Just wanted to report in case it is not expected 😉

Expected Behavior

The mentioned code listing should (probably) compile.

Current Behavior

$ v example.v
example.v:8:5: error: non-bool type `BOOL` used as if condition
    6 |
    7 | fn main() {
    8 |     if example() {
      |        ~~~~~~~~~
    9 |         println('Should work, or not?')
   10 |     }

Reproduction Steps

type BOOL = bool

fn example() BOOL {
	return true
}

fn main() {
	if example() {
		println('Should work, or not?')
	}
}

Possible Solution

I think it would be nice to allow aliases for bool. Sometimes that can be more descriptive.

Additional Information/Context

No response

V version

V full version: V 0.3.3 d60ceb4

Environment details (OS name and version, etc.)

OS: linux, "Manjaro Linux" (VM)

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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant