-
Notifications
You must be signed in to change notification settings - Fork 19
Compute and use constant expressions via the type checker. #35
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
Compute and use constant expressions via the type checker. #35
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #35 +/- ##
=========================================
Coverage ? 65.66%
=========================================
Files ? 4
Lines ? 1031
Branches ? 0
=========================================
Hits ? 677
Misses ? 321
Partials ? 33 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@jgautheron Let's rebase this on your branch so we can keep the tests and CLI changes. I should have time to do so this evening, but feel free to do it sooner if it's blocking anything. |
3c64043 to
78ef201
Compare
78ef201 to
6b10de8
Compare
|
@jgautheron here is a combination of both our branches which ought to be able to go in without breaking anything. |
|
Nice work, lgtm! |
This PR uses Go's type checker to compute and use constant expressions everywhere.
This will close #32 and will additionally support arbitrary numerical calculations when
-numbersis set.It will break compatibility with
golangci-lint, asgoconstwill now require type information to be used. We'll need a PR upstream to plumb it through.This PR ignores type checking errors in several locations. This is because the type checker checks a lot of extraneous information that we do not care about. The type checker can typically determine the value and type of constant expressions even if other errors are found in the file. In case type checking totally fails,
treeVisitorfalls back on its prior behavior.Note: Since this PR casts numbers to strings prior to checking for collisions, we should have a lot more tests for various kinds of large numbers, and especially tests to check different floating point representations.