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

chore: Refactor to make Interpreter not be a visitor #35

Merged
merged 3 commits into from
Feb 1, 2024
Merged

Conversation

danvk
Copy link
Owner

@danvk danvk commented Feb 1, 2024

After puzzling over the visitor pattern in TypeScript, @mulias pointed out that I didn't really need it; pattern matching (via a switch statement) is the more idiomatic way to do this with a tagged union.

This is that refactor. There's a lot fewer imports, at least. No visitor but we still get exhaustiveness checking. For the evaluate method it's via the implicit return. For the execute method on expressions, we have to bake it in more explicitly.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Issue Reference

In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our Contributing Guide. We are closing this pull request for now but you can update the pull request description and reopen the pull request.
The check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (3cbf7d3) 97.74% compared to head (0105fb1) 97.35%.

Files Patch % Lines
src/interpreter.ts 93.66% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #35      +/-   ##
==========================================
- Coverage   97.74%   97.35%   -0.39%     
==========================================
  Files          17       17              
  Lines        1947     1925      -22     
  Branches      291      317      +26     
==========================================
- Hits         1903     1874      -29     
- Misses         43       50       +7     
  Partials        1        1              

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

@danvk danvk merged commit 452b67f into main Feb 1, 2024
13 checks passed
@danvk danvk deleted the visitor-refactor branch February 1, 2024 19:49
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.

1 participant