Skip to content

Apply resugarings also to pre- and postconditions #1945

Closed

Description

@abentkamp

Consider the following example:

#[hax_lib::requires(a[0]==0)]
fn first(a: &mut [i32; 10]) -> i32 {
  a[0]
}

Open this code snippet in the playground

The Lean backend produces a[(0 : usize)]_? for the occurrence of a[0] in the function body but core_models.ops.index.Index.index a (0 : usize) for the occurrence of a[0] in the requires-clause.

The reason for this is that:

Maybe we can apply the resugarings earlier?

Activity

  1. added
    backendIssue in one of the backends (i.e. F*, Coq, EC...)
    leanRelated to the Lean backend or library
    on Feb 12, 2026
  2. abentkamp commented on Feb 18, 2026

    @abentkamp
    ContributorAuthor

    The issue remains, but the example above had been fixed by #1950.

    Here is a different example:

    #[hax_lib::requires({let x = a; a == 0})]
    fn mktuple(a: i32) -> bool {
        {let x = a; a == 0}
    }
    
    

    Open this code snippet in the playground

    The same expression is translated as let x : i32 := a; in the function body and as let x : i32 ← (pure a); in the precondition because the LetPure resugaring is only applied to the function body.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendIssue in one of the backends (i.e. F*, Coq, EC...)leanRelated to the Lean backend or library

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions