-
Notifications
You must be signed in to change notification settings - Fork 64
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
enhancement: Expand usage of resolve_constant
and add support for variables
#304
Conversation
@@ -20,22 +20,27 @@ impl Query { | |||
// TODO: | |||
// - error when trying to index into object | |||
// - error when trying to path into array | |||
#[must_use] |
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.
Perhaps it's better to apply #[must_use]
to the struct Query
.
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 that mean the same thing? These were from clippy
suggestions (I'm not sure why it wanted it on these functions all of a sudden)
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 tried it, unfortunately clippy starts complaining if I only put it on the struct itself 😞
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.
Ah I see, thanks for trying it out. This might happen because std::hint::must_use is still experimental.
related: #151
closes: #114
Expr::resolve_constant
tries to resolve an expression with only compile-time information. This implementation has been improved to also resolve variables if the value of the variable is known at compile-time.This is something that is useful for
ArgumentList
functions, such asArgumentList::required_regex
, so for example a variable with a literal regex can be used where a literal regex is required.All of the
ArgumentList::*
functions were updated to useExpr::resolve_constant
where approriate, so they can also resolve literal variables (and any other improvements that may come with theresolve_const
function in the future).There was also an internal refactor for the
resolve_constant
function. TheTypeState
is the "source of truth" for compile-time information, including variables with known values. TheVariable
expression also included this. This was removed and now theTypeState
is always used.