Skip to content

Instantly share code, notes, and snippets.

@isidentical
Created June 13, 2021 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isidentical/820863d5e97576c8bc06ca4fd8fefc28 to your computer and use it in GitHub Desktop.
Save isidentical/820863d5e97576c8bc06ca4fd8fefc28 to your computer and use it in GitHub Desktop.
Query:
FunctionDef(body=[*..., Return(Call())])
AST:
Match(
name="FunctionDef",
filters={
"body": List(
items=[
Expand,
Match(
name="Return",
filters={
"value": Match(
name="Call",
filters={},
positional=True,
)
},
positional=True,
),
]
)
},
positional=True,
)
Generated IR:
SELECT ast::FunctionDef
FILTER (
WITH
sequence_f1e35975 := array_agg((
SELECT .body
ORDER BY @index
))
SELECT sequence_f1e35975[-1][IS ast::Return].value IS ast::Call AND len(sequence_f1e35975) >= 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment