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

Unused Variable Warnings #1033

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open

Unused Variable Warnings #1033

wants to merge 6 commits into from

Conversation

lmulcahy21
Copy link
Contributor

The basic functionality of the warnings works correctly, printing "unused [var name]" or "used [var name]" to the console.

Would love review on these changes, as this does alter some of the core functionality of the backend, as well as the function definition for upat_to_info_map.

After review and revision, next step is to merge in the adt-defs-refutable branch and implement a warning for this, so that the variable is highlighted in place.

@lmulcahy21 lmulcahy21 added starter-project needs-polish for PRs that are substantially complete but need final polish labels May 27, 2023
@lmulcahy21 lmulcahy21 requested a review from disconcision May 27, 2023 18:14
@lmulcahy21 lmulcahy21 changed the title Basic functionality working, prints correctly to console Unused Variable Warnings May 27, 2023
Copy link
Member

@disconcision disconcision 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! Some cleanup and case/lambda still need wiring up. Then prob good to proceed with bringing in warnings code

src/haz3lcore/statics/Ctx.re Outdated Show resolved Hide resolved
src/haz3lcore/statics/Statics.re Outdated Show resolved Hide resolved
src/haz3lcore/statics/Statics.re Outdated Show resolved Hide resolved
@lmulcahy21
Copy link
Contributor Author

Just made a commit implementing most of these suggestions, but needs more time/work for debugging case statements. They currently aren't evaluating and the use of a variable in the case statement isn't counting as a "use" for the state of the variable, and im pretty sure it has something to do with an empty free/co-ctx instead of a properly created/propagated one

@cyrus- cyrus- marked this pull request as draft June 10, 2023 02:29
Base automatically changed from adt-defs-after to dev August 6, 2023 22:21
@lmulcahy21 lmulcahy21 force-pushed the unused-var-warnings branch from 12be83c to b8ac46d Compare April 11, 2024 18:33
@lmulcahy21
Copy link
Contributor Author

UVWs are working, with a basic warning interface outlined through the Info module. Would love to get feedback on it, as many things could use improvement, such as the names of warnings, info that each displays, how they are found, etc.

@cyrus-
Copy link
Member

cyrus- commented Apr 11, 2024

Nice work!

It isn't handling recursive functions correctly, so maybe look into that:
image

Another thing we should think about is how to handle variables where there is an empty expression hole in the scope. We think of holes as being potentially filled by anything, including that unused variable, so in such a case I would call the variable "possibly unused" rather than "definitely unused". I think we should hold off on displaying the warning marker in that situation.

@lmulcahy21
Copy link
Contributor Author

lmulcahy21 commented Apr 13, 2024

Also not working correctly for case statements, will look into this

image

@lmulcahy21 lmulcahy21 removed the needs-polish for PRs that are substantially complete but need final polish label May 14, 2024
@lmulcahy21 lmulcahy21 marked this pull request as ready for review May 14, 2024 18:16
@cyrus-
Copy link
Member

cyrus- commented May 28, 2024

@lmulcahy21

  • need to resolve some merge conflicts
  • the message in the cursor inspector needs to be human-readable
  • we need to have it so if there is a hole in the scope of a variable, we don't show unused variable warnings, otherwise we end up with stuff like this in exercises mode where odd is showing as unused because it isn't explicitly used in the "in" portion (but it will be referred to by the tests etc. downstream in exercises mode):
image

@cyrus- cyrus- marked this pull request as draft May 30, 2024 19:43
@lmulcahy21 lmulcahy21 force-pushed the unused-var-warnings branch from 35e01fe to bf4da10 Compare June 14, 2024 02:04
@lmulcahy21
Copy link
Contributor Author

Had a boxing match with git and lost (had to force push) but warnings now (inelegantly) don't display if there is a hole in the co-context; done with a __hole__ variable in the co-context, as i didn't want to change the current co-ctx's interface

Copy link
Member

@disconcision disconcision left a comment

Choose a reason for hiding this comment

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

looking pretty good but wondering about a couple details of the approach

src/haz3lcore/statics/Statics.re Show resolved Hide resolved
src/haz3lcore/statics/Statics.re Show resolved Hide resolved
src/haz3lcore/statics/Statics.re Outdated Show resolved Hide resolved
src/haz3lweb/www/style.css Outdated Show resolved Hide resolved
src/haz3lcore/statics/Info.re Outdated Show resolved Hide resolved
src/haz3lcore/statics/CoCtx.re Show resolved Hide resolved
@lmulcahy21 lmulcahy21 marked this pull request as ready for review June 25, 2024 19:54
@lmulcahy21 lmulcahy21 requested a review from disconcision June 26, 2024 14:54
@cyrus- cyrus- mentioned this pull request Jul 25, 2024
@cyrus- cyrus- marked this pull request as draft July 25, 2024 18:47
@lmulcahy21 lmulcahy21 force-pushed the unused-var-warnings branch from b992ce0 to ac40f00 Compare August 6, 2024 17:05
@lmulcahy21 lmulcahy21 marked this pull request as ready for review August 6, 2024 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants