Skip to content

Document set comprehension lowering and backend wire representation#224

Open
gordonwatts wants to merge 1 commit intomasterfrom
codex/implement-visit_setcomp-in-syntatic_sugar.py
Open

Document set comprehension lowering and backend wire representation#224
gordonwatts wants to merge 1 commit intomasterfrom
codex/implement-visit_setcomp-in-syntatic_sugar.py

Conversation

@gordonwatts
Copy link
Member

Motivation

  • Clarify how set comprehensions are handled by the syntatic-sugar transformer so users and backends understand when a set is lowered to a literal and when it fails.
  • Explain the exact AST nodes that are emitted and sent over the func_adl wire so backends can rely on a stable, backend-agnostic representation.

Description

  • Implemented lowering for set comprehensions in func_adl/ast/syntatic_sugar.py via visit_SetComp, which inlines literal iterables to ast.Set, emits set() for empty results, and raises ValueError (including ast.unparse(node)) for non-literal iterables.
  • Added tests in tests/ast/test_syntatic_sugar.py verifying literal set lowering, empty-literal lowering to set(), and error behavior for non-literal iterables.
  • Updated documentation in README.md and docs/source/generic/query_structure.md to document the syntactic-sugar behavior for set comprehensions and to describe what AST form (ast.Set or set() call) is sent to the backend when .value() is called.

Testing

  • Ran pytest tests/ast/test_syntatic_sugar.py and all tests passed (45 passed).
  • Ran black --check func_adl tests and it completed with no formatting changes required.
  • Ran flake8 func_adl tests with no linting issues reported.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant