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

parser: Add unused var check #24

Merged
merged 3 commits into from
Oct 6, 2022
Merged

parser: Add unused var check #24

merged 3 commits into from
Oct 6, 2022

Conversation

juliaogris
Copy link
Member

@juliaogris juliaogris commented Oct 5, 2022

Add unused var check reporting an error if declared variable is never
used. This feature was yet again borrowed from go and piggy backed on
the scope data structure.

Refactor validateVar to validateVarDecl as it seems the more
appropriate name.

@github-actions
Copy link

github-actions bot commented Oct 5, 2022

Visit the preview URL for this PR (updated for commit eb090bd):

https://evy-lang--pr24-unused-decl-nux50pp5.web.app

(expires Wed, 12 Oct 2022 12:13:51 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@juliaogris juliaogris force-pushed the unused-decl branch 3 times, most recently from 8e75fdd to 78fb9bf Compare October 6, 2022 00:49
@juliaogris
Copy link
Member Author

Hi from GitHub CLI

@juliaogris juliaogris force-pushed the unused-decl branch 4 times, most recently from 0450cdf to 2237001 Compare October 6, 2022 05:13
Copy link
Member

@camh- camh- left a comment

Choose a reason for hiding this comment

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

LGTM. just a couple of nits but otherwise nice how short it is.

pkg/parser/parser_test.go Outdated Show resolved Hide resolved
pkg/parser/parser_test.go Outdated Show resolved Hide resolved
pkg/parser/parser.go Show resolved Hide resolved
@juliaogris juliaogris force-pushed the unused-decl branch 2 times, most recently from 6da552f to 0103456 Compare October 6, 2022 10:30
Rename validateVar to validateVarDecl as it is more accurate and less
confusing on revisit: validateVarDecl ensures that a declartion of a
variable doesn't use a function name or an already declared variable
name from same local scope.
Fix location for unknown variable error message so that it actually
points to the column where the unknown variable starts and not to the
next token after it.
Add unused var check reporting an error if declared variable is never
used. This feature was yet again borrowed from go and piggy backed on
the scope data structure.
Copy link
Member

@camh- camh- left a comment

Choose a reason for hiding this comment

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

🥗

@juliaogris juliaogris merged commit 19f6090 into master Oct 6, 2022
@juliaogris juliaogris deleted the unused-decl branch October 6, 2022 10:55
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