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

Typed constants are not constants? #19571

Closed
Delta456 opened this issue Oct 15, 2023 Discussed in #19570 · 0 comments · Fixed by #19572
Closed

Typed constants are not constants? #19571

Delta456 opened this issue Oct 15, 2023 Discussed in #19570 · 0 comments · Fixed by #19572
Assignees
Labels
Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@Delta456
Copy link
Member

Delta456 commented Oct 15, 2023

Discussed in #19570

Originally posted by alfaus October 15, 2023
If you use a typed constant in a match range expression, for example:

const (
  a = u16(1)
  b = u16(5)
)
c := u16(3)
match c {
  a...b { println('1...5') }
  else { println('not 1...5') }
}

you get a compiler error: 'match branch range expressions need the start value to be known at compile time (only enums, const or literals are supported)'
Maybe u16(1) is not a type conversion but a function call? I've read functions in constant definition are evaluated at runtime.

I don't know if this is a bug or a feature...

> [!NOTE] > You can vote for this issue using the 👍 reaction. More votes increase the issue's priority for developers. > > Take into account that only the 👍 reaction counts as a vote. > Only reactions to the issue itself will be counted as votes, not comments.
@Delta456 Delta456 added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Oct 15, 2023
@Delta456 Delta456 self-assigned this Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unit: Checker Bugs/feature requests, that are related to the type checker.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant