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

feat: Update type parsing to use new diagnostics #605

Merged
merged 8 commits into from
Nov 11, 2024

Conversation

mark-koch
Copy link
Collaborator

No description provided.

@mark-koch mark-koch requested a review from a team as a code owner October 29, 2024 16:07
@mark-koch mark-koch requested review from acl-cqc and removed request for a team October 29, 2024 16:07
@codecov-commenter
Copy link

codecov-commenter commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 17 lines in your changes missing coverage. Please review.

Project coverage is 92.49%. Comparing base (16d84b5) to head (52e7221).
Report is 6 commits behind head on feat/diagnostics.

Files with missing lines Patch % Lines
guppylang/tys/parsing.py 56.52% 10 Missing ⚠️
guppylang/definition/struct.py 95.34% 2 Missing ⚠️
guppylang/tys/errors.py 97.67% 2 Missing ⚠️
guppylang/definition/function.py 80.00% 1 Missing ⚠️
guppylang/definition/value.py 0.00% 1 Missing ⚠️
guppylang/tys/builtin.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##           feat/diagnostics     #605      +/-   ##
====================================================
+ Coverage             91.75%   92.49%   +0.74%     
====================================================
  Files                    61       66       +5     
  Lines                  6633     7250     +617     
====================================================
+ Hits                   6086     6706     +620     
+ Misses                  547      544       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

annotate_location(expr_ast, source, info.filename, 0)
annotate_location(expr_ast, source, info.filename, 1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Drive-by: Our new spans start counting lines at 1

Copy link
Contributor

Choose a reason for hiding this comment

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

As per documentation on Loc, indeed

Copy link
Contributor

Choose a reason for hiding this comment

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

But columns starting at 0? :(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Columns also start at 1, but that's the same in Python AST afaik, so it works out without having to modify it

Copy link
Contributor

@acl-cqc acl-cqc left a comment

Choose a reason for hiding this comment

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

Looks good, ta. (Though I note there are quite a few TODOs!)

def rendered_title(self) -> str:
if self.expected > self.actual:
return "Missing type arguments"
elif 0 == self.expected < self.actual:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this case is a bit confusing - I mean, the assumption is that expected>=0 and actual>=0 and expected!=actual in which case the < self.actual here is redundant. I'd just be consistent with rendered_span_label i.e. check self.expected == 0 first and then the other two.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively the special case of expected == 0 might be neater as a separate error

@@ -1,6 +1,8 @@
Guppy compilation failed. Error in file $FILE:11
Error: Invalid annotation (at $FILE:11:16)
Copy link
Contributor

Choose a reason for hiding this comment

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

driveby: at $FILE? Not at nonlinear.py or even at <stdin> ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is only a placeholder in the golden value. The testing framework replaces it with the actual path (which will be different on every machine that cloned the repo)

var_def: "ParamDef"

@dataclass(frozen=True)
class Explain(Note):
Copy link
Contributor

Choose a reason for hiding this comment

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

You might consider giving FreeTypeVarError a __post_init__ that does the self.add_sub_diagnostic(Explain(None)), as it looks easy for the caller (analyser) to forget the help message, and I'm not sure I see the Caller ever providing any parameter other than None (e.g. another span??)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, there are a lot more places where we could do this 👍

See #620

annotate_location(expr_ast, source, info.filename, 0)
annotate_location(expr_ast, source, info.filename, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

As per documentation on Loc, indeed

annotate_location(expr_ast, source, info.filename, 0)
annotate_location(expr_ast, source, info.filename, 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

But columns starting at 0? :(

Base automatically changed from diag/defs to feat/diagnostics November 11, 2024 13:48
@mark-koch mark-koch merged commit c4a2aca into feat/diagnostics Nov 11, 2024
2 checks passed
@mark-koch mark-koch deleted the diag/tys branch November 11, 2024 13:56
github-merge-queue bot pushed a commit that referenced this pull request Nov 11, 2024
This is the development branch for our new diagnostics infrastructure.
Tracked by #535.

*  #548
* #551
* #552 
* #553
* #586
* #588
* #587
* #589 
* #590
* #600
* #601
* #604 
* #605 
* #606
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