Skip to content

Using a named constant in an alt branch binds the value to that name instead #1688

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

Closed
jdm opened this issue Jan 27, 2012 · 1 comment
Closed
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR)

Comments

@jdm
Copy link
Contributor

jdm commented Jan 27, 2012

const FOO: int = 0;
const BAR: int = 1;

fn main() {
    alt 1 {
      FOO { #debug("FOO") }
      BAR { #debug("BAR") }
    };
}

yields the following error:

constalt.rs:7:6: 7:9 error: unreachable pattern
constalt.rs:7       BAR { #debug("BAR") }
                    ^~~

If this is expected, it's counter-intuitive.

@marijnh
Copy link
Contributor

marijnh commented Jan 28, 2012

This is a dup of #1193. It could be made to work, using the same no-shadowing rule that's used for tag variant names, but I guess it's not a short-term priority.

@marijnh marijnh closed this as completed Jan 28, 2012
Kobzol pushed a commit to Kobzol/rust that referenced this issue Dec 30, 2024
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR)
Projects
None yet
Development

No branches or pull requests

2 participants