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

Improve MissingColonColon diagnostic. #5926

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

ilyalesokhin-starkware
Copy link
Contributor

@ilyalesokhin-starkware ilyalesokhin-starkware commented Jul 1, 2024

This change is Reviewable

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/diagnostic_test_data/tests line 752 at r1 (raw file):


//! > expected_diagnostics
error: Expected variable or constant, found function.

This is generated here:

resolved_item => Err(ctx.diagnostics.report(

I'm not sure that getting a function when resolving a path is actually wrong, I guess the issue is that we don't have types for functions.

Code quote:

error: Expected variable or constant, found function.

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/diagnostic_test_data/tests line 762 at r1 (raw file):

                 ^

error: Type annotations needed. Failed to infer ?0.

I'm looking into where this is generated.

Code quote:

error: Type annotations needed. Failed to infer ?0.

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 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)


crates/cairo-lang-semantic/src/diagnostic_test_data/tests line 752 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

This is generated here:

resolved_item => Err(ctx.diagnostics.report(

I'm not sure that getting a function when resolving a path is actually wrong, I guess the issue is that we don't have types for functions.

function will be a type of a constants if we have an Fn sort of trait. but that is not currently the case.
It makes sense to me this will change when we go though the process of adding closures.


crates/cairo-lang-semantic/src/diagnostic_test_data/tests line 762 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

I'm looking into where this is generated.

cool.

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/diagnostic_test_data/tests line 762 at r1 (raw file):

Previously, orizi wrote…

cool.

It is generated here:

get_core_trait_function_infer(

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/diagnostic_test_data/tests line 762 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

It is generated here:

get_core_trait_function_infer(

it seems that there is some "missing" propagation.
but it makes sense to me for this to go to a following PR.

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

                }
            }
            SemanticDiagnosticKind::MissingColonColon => "Are you missing a `::`?.".into(),

Should I rename it to:
MaybeMissingColonColon
?

Suggestion:

MaybeMissingColonColon

Copy link
Member

@mkaput mkaput 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, 3 unresolved discussions (waiting on @ilyalesokhin-starkware and @orizi)


crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

                }
            }
            SemanticDiagnosticKind::MissingColonColon => "Are you missing a `::`?.".into(),

this is total nitpick from my side, but I don't like using questions as diagnostics

to given an example, this is what Rust does here:

use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=41b500ebab6cad26b18da195036848e5

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, 3 unresolved discussions (waiting on @ilyalesokhin-starkware)


crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

Should I rename it to:
MaybeMissingColonColon
?

Yeah, makes sense

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

Previously, mkaput (Marek Kaput) wrote…

this is total nitpick from my side, but I don't like using questions as diagnostics

to given an example, this is what Rust does here:

use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=41b500ebab6cad26b18da195036848e5

The issue is that it is not clear what the error is.

Copy link
Member

@mkaput mkaput 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, 3 unresolved discussions (waiting on @ilyalesokhin-starkware)


crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

The issue is that it is not clear what the error is.

yeah you're right

what about?

invalid path syntax, use `::<...>` instead of `<...>` to specify...

Copy link
Member

@mkaput mkaput 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, 3 unresolved discussions (waiting on @ilyalesokhin-starkware)


crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

Previously, mkaput (Marek Kaput) wrote…

yeah you're right

what about?

invalid path syntax, use `::<...>` instead of `<...>` to specify...

though I do not want to block this, so we can ignore this comment

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

Previously, mkaput (Marek Kaput) wrote…

though I do not want to block this, so we can ignore this comment

Are you confident that if you have
a < b
and you can't resolve 'a', then the issue is missing ::?

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)

Copy link
Member

@mkaput mkaput 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/diagnostic.rs line 813 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

Are you confident that if you have
a < b
and you can't resolve 'a', then the issue is missing ::?

hmm, no I cannot be certain. there would have to be a matching > to be certain I think

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

Previously, mkaput (Marek Kaput) wrote…

hmm, no I cannot be certain. there would have to be a matching > to be certain I think

I think we will have to change the parser to be sure about the error here.

Copy link
Member

@mkaput mkaput 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/diagnostic.rs line 813 at r1 (raw file):

Previously, ilyalesokhin-starkware wrote…

I think we will have to change the parser to be sure about the error here.

makes sense. ignore my comment then

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.

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ilyalesokhin-starkware)

@ilyalesokhin-starkware
Copy link
Contributor Author

crates/cairo-lang-semantic/src/diagnostic.rs line 813 at r1 (raw file):

Previously, orizi wrote…

Yeah, makes sense

done

@ilyalesokhin-starkware ilyalesokhin-starkware added this pull request to the merge queue Jul 2, 2024
Merged via the queue into dev-v2.7.0 with commit cf17397 Jul 2, 2024
43 checks passed
@orizi orizi deleted the ilya/missing_diag branch July 3, 2024 12:25
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