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

Add additional helpful spans to opaque struct field access diagnostics #862

Merged
merged 5 commits into from
Nov 6, 2024

Conversation

vrindisbacher
Copy link
Collaborator

@vrindisbacher vrindisbacher commented Oct 26, 2024

See here

@vrindisbacher
Copy link
Collaborator Author

Closes (#835).

@vrindisbacher
Copy link
Collaborator Author

@nilehmann, is there a straight forward way to get the span for the wrapping function? I only know how to get the struct's (and it's related impls) span, since it seems like the span for the field access in the function body has no parent.

@nilehmann
Copy link
Member

no, there's no easy way right now. When we construct a CheckerError we only pass the Span of the current Statement being checked and I don't think you can go from that to the span of the containing function. However, I think we don't emit CheckerErrors in too many places so something we could try is not implement Diagnostic for CheckerError this will point to all the places where we emit it and hopefully we will have the DefId of the function at those places, for example, here https://github.com/flux-rs/flux/blob/main/crates/flux-refineck/src/lib.rs/#L154. At those places, we can call a helper function that takes a GlobalEnv, a CheckerError, and the DefId of the containing function, it then constructs the Diag and emits it.

@vrindisbacher vrindisbacher force-pushed the vrindisbacher/opaque-struct-field-access branch from d50fe31 to 361db23 Compare November 6, 2024 17:46
@vrindisbacher vrindisbacher force-pushed the vrindisbacher/opaque-struct-field-access branch from 666e636 to 67ee369 Compare November 6, 2024 19:36
@vrindisbacher
Copy link
Collaborator Author

Hmm, not sure why the CI stuff is failing. It builds fine locally, and the line it's complaining about is different than what the dialog points to...

@nilehmann
Copy link
Member

@vrindisbacher I think you local branch is too old. The ci is failing because it runs on the code after being merged with main.

@vrindisbacher vrindisbacher force-pushed the vrindisbacher/opaque-struct-field-access branch from 67ee369 to 0e1ec54 Compare November 6, 2024 20:46
@vrindisbacher vrindisbacher merged commit 4d0670f into main Nov 6, 2024
7 checks passed
@vrindisbacher vrindisbacher deleted the vrindisbacher/opaque-struct-field-access branch November 6, 2024 20:51
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.

2 participants