Skip to content

Fix translation of const to respect visibility#2076

Draft
Lysxia wants to merge 12 commits intomasterfrom
const-simp
Draft

Fix translation of const to respect visibility#2076
Lysxia wants to merge 12 commits intomasterfrom
const-simp

Conversation

@Lysxia
Copy link
Copy Markdown
Collaborator

@Lysxia Lysxia commented Apr 28, 2026

Close #2009

  • add #[ensures] for consts
  • add an opacity check for consts (my plan is that the body of a const is as visible as the const itself unless it has an #[ensures])
  • add an attribute to force the evaluation of consts. Currently this is the default and this current PR adds an attribute to disable it as a stop-gap, but it's a bad default because it breaks opacity. We need to keep the ability to evaluate consts because MIN and MAX for machine integers are defined using bitwise operations (isize::MIN = !isize::MAX, isize::MAX = (usize::MAX >> 1) as isize, usize::MAX = !0), and we don't want to expose these definitions to users.
  • Translate consts to verify their type invariants.
  • In the translation of terms, when we encounter a non-visible constructor (due to an evaluated const), replace it with an opaque constant and emit a warning.

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.

ERROR_UNBOUND emitted when constants, structs and modules are combined

1 participant