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

Panic when a dependency is misconfigured. #6858

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

ilyalesokhin-starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/resolve/mod.rs line 1290 at r1 (raw file):

                    get_long_id(dep_crate_id),
                    configs.keys().cloned().map(get_long_id).collect_vec()
                );

Invalid crate dependency: Real { name: "bounded_int2", discriminator: Some("bounded_int") }
Configured crates: [
Real {
name: "core",
discriminator: None,
},
Real {
name: "stwo_cairo_verifier",
discriminator: Some(
"stwo_cairo_verifier",
),
},
Real {
name: "bounded_int2",
discriminator: Some(
"bounded_int2",
),
},
]

Code quote:

                panic!(
                    "Invalid crate dependency: {:?}\nconfigured crates: {:#?}",
                    get_long_id(dep_crate_id),
                    configs.keys().cloned().map(get_long_id).collect_vec()
                );

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/resolve/mod.rs line 1290 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

Invalid crate dependency: Real { name: "bounded_int2", discriminator: Some("bounded_int") }
Configured crates: [
Real {
name: "core",
discriminator: None,
},
Real {
name: "stwo_cairo_verifier",
discriminator: Some(
"stwo_cairo_verifier",
),
},
Real {
name: "bounded_int2",
discriminator: Some(
"bounded_int2",
),
},
]

here is an example:

Code snippet:

Invalid crate dependency: Real { name: "bounded_int2", discriminator: Some("bounded_int") }
Configured crates: [
    Real {
        name: "core",
        discriminator: None,
    },
    Real {
        name: "stwo_cairo_verifier",
        discriminator: Some(
            "stwo_cairo_verifier",
        ),
    },
    Real {
        name: "bounded_int2",
        discriminator: Some(
            "bounded_int2",
        ),
    },
]

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


crates/cairo-lang-semantic/src/resolve/mod.rs line 1289 at r1 (raw file):

                    "Invalid crate dependency: {:?}\nconfigured crates: {:#?}",
                    get_long_id(dep_crate_id),
                    configs.keys().cloned().map(get_long_id).collect_vec()

oh - we should probably just filter to the relevant crate without discriminator.

Code quote:

                    "Invalid crate dependency: {:?}\nconfigured crates: {:#?}",
                    get_long_id(dep_crate_id),
                    configs.keys().cloned().map(get_long_id).collect_vec()

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


crates/cairo-lang-semantic/src/resolve/mod.rs line 1291 at r1 (raw file):

                    configs.keys().cloned().map(get_long_id).collect_vec()
                );
            }

oh - we should probably just filter to the relevant crate without discriminator.

Suggestion:

                panic!(
                    "Invalid crate dependency `{ident}: got discriminator {:?}\nconfigured discriminators: {:#?}",
                    dep.discriminator,
                    configs.keys().cloned().map(|crate_id|crate_id.lookup_intern(self.db).discriminator).collect_vec()
                );
            }

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


crates/cairo-lang-semantic/src/resolve/mod.rs line 1291 at r1 (raw file):

Previously, orizi wrote…

oh - we should probably just filter to the relevant crate without discriminator.

i mean .filter_map(|crate_id| { let long_id = crate_id.lookup_intern(self.db); (long_id.name == ident).and_then(long_id.discriminator) })

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/resolve/mod.rs line 1291 at r1 (raw file):

Previously, orizi wrote…

i mean .filter_map(|crate_id| { let long_id = crate_id.lookup_intern(self.db); (long_id.name == ident).and_then(long_id.discriminator) })

The name could also be wrong.

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed, 1 unresolved discussion

@ilyalesokhin-starkware ilyalesokhin-starkware added this pull request to the merge queue Dec 17, 2024
Merged via the queue into main with commit 08a55d4 Dec 17, 2024
48 checks passed
@orizi orizi deleted the ilya/dep_check branch December 22, 2024 09:56
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.

3 participants