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

bug: semantic expr compute fails: no entry found for key #7071

Closed
enitrat opened this issue Jan 13, 2025 · 1 comment · Fixed by #7077
Closed

bug: semantic expr compute fails: no entry found for key #7071

enitrat opened this issue Jan 13, 2025 · 1 comment · Fixed by #7077
Assignees
Labels
bug Something isn't working

Comments

@enitrat
Copy link
Contributor

enitrat commented Jan 13, 2025

Bug Report

Cairo version:

scarb 2.9.2+nightly-2025-01-11 (a27b72f82 2025-01-11)
cairo: 2.9.2 (dff35c09b)
sierra: 1.6.0

Problem

fn call_with<F, +Drop<F>, +core::ops::Fn<F, (A,)>[Output: usize]>(func: F) -> usize {
    func(A{inner: array![]})
}


#[derive(Drop)]
struct A{
    inner: Array<usize>
}

fn main() {
    let aclosure = |a: A| {
        a.inner.append(3);
        *a.inner[0]
    };
    call_with(aclosure);
}

scarb cairo-run fails with:

thread 'scarb compile tmp-klgon66pi5siu' panicked at /Users/runner/.cargo/git/checkouts/cairo-f086c7e6d4098a68/dff35c0/crates/cairo-lang-semantic/src/expr/compute.rs:3267:34:
no entry found for key
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at scarb/src/ops/compile.rs:197:14:
Compiler thread has panicked.: Any { .. }

I was actually expecting this to NOT compile as I thought a non-copyable type would not implement FnMut.

@enitrat enitrat added the bug Something isn't working label Jan 13, 2025
@orizi orizi linked a pull request Jan 14, 2025 that will close this issue
@orizi
Copy link
Collaborator

orizi commented Jan 14, 2025

Fixed in attached PR.

@orizi orizi closed this as completed Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants