bpftrace
bpftrace copied to clipboard
Allow logical operators on more types
Logical operators currently only work on integer types, using any other type fails with:
ERROR: Type mismatch for '&&': comparing 'int64' with 'string[64]'
I think we can define a truthy/false value for (almost ) all types, like an empty string could be false and non empty evaluating to true.
One case to keep in mind is maps, say we have
BEGIN { @[1]="" }
i:s:1 /@[1]/ { print(xxx) }
Do we use the map value (and empty string evaluating to false) or the fact that the map has a value. We need to stay compatible here.
Relates /expands #1579
How would truthiness work for structs?
@danobi don't think we'd be able to have it defined for structs. For pointer types yes (null -> falsey), but not structs.