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

Don't eval constants eagerly #895

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

Nadrieril
Copy link
Collaborator

@Nadrieril Nadrieril commented Sep 18, 2024

I made a mistake in my last PR: evaluating constants eagerly is semantically incorrect. For example, this is valid rust:

pub trait HasLen {
    const LEN: usize;
}

impl<const N: usize> HasLen for [bool; N] {
    const LEN: usize = if true {
        N
    } else {
        <Self as HasLen<N>>::LEN
    };
}

but eagerly evaluating causes cycle errors. Promoted constants however should be evaluatable since they're only promoted when they're infallible.

@W95Psp W95Psp added this pull request to the merge queue Sep 18, 2024
Merged via the queue into hacspec:main with commit ad07376 Sep 18, 2024
12 of 13 checks passed
@Nadrieril Nadrieril deleted the dont-eval-constants-eagerly branch September 18, 2024 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants