-
Notifications
You must be signed in to change notification settings - Fork 227
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 runtime checks for builder position #436
Conversation
src/builder.rs
Outdated
#[derive(Error, Debug, PartialEq, Eq)] | ||
pub enum BuilderError { | ||
#[error("Builder position is not set")] | ||
PositonError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: Position
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe UnsetPosition
would be a better name? It's sorta redundant to have Error in the variant name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Changing that now - and I will also run typos
over Inkwell. Perhaps adding typos
can be added to CI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know about typos
before - could you open a ticket please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will open it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great; thank you for all of the great work and cleanup!
Glad to help! |
#[error("GEP error: does not point to a struct or index is out of bounds")] | ||
GEPError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this solve #213?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[error("GEP error: does not point to a struct or index is out of bounds")] | ||
GEPError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called GEPError
, in my head it goes like "any GEP error goes into this variant", but there are actually 2 other GEP error variants.
I'd say this one should have a different name or be broken down into more variants.
WDYT? Is this worth an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the GEPError
on my fork. Turns out, GEPPointee
and GEPIndex
are all that were needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I reopen another PR?
Edit: I will bundle these changes in my next PR regarding typos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh nice, I'd say yes! But we can wait for TheDan to be 100% sure.
Edit: I just saw your edit. 😆
I added an
assert_eq
to check that the builder has a position set in everybuild_*
method, which improves safety.Description
I added an
enum
to keep track of the state, which was added to theBuilder
struct. The state on construction isNotSet
, and theposition_*
methods are used to set the state toSet
. I factored out the rawassert_eq
into a macro to improve code readability.Related Issue
This resolves the problem discussed in #425.
How This Has Been Tested
I ran the tests locally on my WSL2 Ubuntu 22.04, as well as the Github Actions on my fork, all of which passed.
Checklist