Pattern matching for TupleGetItem


is it currently possible to match TupleGetItem for an arbitrary index? if not, would it be a permissible patch to add this (maybe with index=-1 internally and a second constructor facing the public)?

Best regards


As you mentioned, that will need to extend the TupleGetItemPattern to allow unspecified index. Currently I can only come up with the following workaround:

op = is_op(...)
out = is_tuple_get_item(op, 0) | is_tuple_get_item(op, 1) | is_tuple_get_item(op, 2)

cc @mbrookhart

@t-vi Sure, if you want to extend it, Iā€™m okay with that. Iā€™m not sure we need an extra API, maybe just make the arbitrary value default?

Yeah. I would suggest enhancing the current one to is_tuple_get_item(pat: DFPattern, index: Optional[int] = None).

1 Like

Thank you.

Best regards