Skip to content

Conversation

fw-immunant
Copy link
Contributor

@fw-immunant fw-immunant commented Oct 3, 2025

Mentioning enum variants, etc. in const contexts doesn't have the same scoping problems as variables. This change narrows the exception to const macro translation for DeclRefs and makes it more distinct from what #1386 covers.

for example, mentioning enum constants should be accepted in const contexts
@fw-immunant fw-immunant force-pushed the fw/const-macros-declref-variable branch from eb21b12 to 102f436 Compare October 3, 2025 16:09
self.ast_context.display_loc(src_loc),
"Cannot yet refer to declarations in a const expr",
));
if let CDeclKind::Variable { .. } = decl {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do this initially because I wasn't sure about other declarations within a function and how that interacted with global scope, so I wanted to err on the safer side, since this is supposed to be temporary.

return LATE_INIT_VAR;
}

enum foo { Variant1, };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work if this is defined within a function, the macro is defined outside of it, and used within it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants