You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a missing piece in the filtering.Declarations type, which doesn't include the constants true and false, or a way to declare those constants. There is a function NewConstantDeclaration(), which is used internally, but there's no public API to use the output as a declaration.
I had to add two new "ident" declarations to work around this:
And then while walking over the parsed expression tree, where I pull out the constants like int64s, strings, etc, I do a check first, to see if it's an ident:
// var curr *expr.Exprident:=curr.GetIdentExpr()
ifident!=nil {
ifident.Name=="true" {
// treat as a `true` constant
} elseifident.Name=="false" {
// treat as a `false` constant
}
}
constant:=curr.GetConstExpr()
ifconstant!=nil {
switchkind:=constant.Kind.(type) {
// etc
It would be nice if true and false were part of the standard declarations, but I get why they aren't.
As an alternative, it would be great if filtering.Declarations.declare(*expr.Decl) were exported as an escape hatch for more advanced uses, or possibly a function like
When i try to use bool variable in has statement,
filter like bottom, and i always got Constant_StringValue type
so, I try to strings.ParseBool to get bool variable,but how can'i check explicit string declaration between a.c:"true" and a.c:true
The text was updated successfully, but these errors were encountered: