Skip to content

fix(language): a macro template nothing calls is held to every rule a call site is - #628

Merged
FBumann merged 2 commits into
claude/blissful-heisenberg-z5rpwo-where-nodesfrom
claude/blissful-heisenberg-z5rpwo-template
Sep 23, 2026
Merged

FBumann merged 2 commits into
claude/blissful-heisenberg-z5rpwo-where-nodesfrom
claude/blissful-heisenberg-z5rpwo-template

Conversation

@FBumann

@FBumann FBumann commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Prompt: Review the packages code as a whole. Do you see room for simplififcation? Or reuction of concepts? … Lets tackle that. With stacked PRs.

Note

The following content was generated by AI.

_check_template_names was a second resolver that checked only names. It is deleted. The resolver now checks a template, with the template's formals left bare. So a template now gets every refusal that a call site gets. Stacked on #627.

Method, gate output, alternatives

What this changes

  • _Resolver has a formals field, and resolve_expression(..., formals=) passes it in. A formal stays bare in a value, edge=, a dimension kwarg, dual(), and by= with its column roles.
  • validation._check_template_names (69 lines) is deleted.
  • The listing of unknown names still puts the formals first, and dual(), over= and by= say "or a formal of this macro".

Found in review, fixed in the second commit

  • A formal along= beside by=/within=, such as shift(x, along=d, offset=1, by=tg, within=g), was handed to the partition as a dimension and refused as 'tg' has no key column over 'd', even with a valid call. A formal along= now builds no partition, and the call site does.
  • sum(x, by=nope, over=a, into=b) with a and b formals loaded, because the formal columns sent the call back before the relation was read. The relation is read first.
  • The over= and by= refusals had lost "or a formal of this macro".

The five tests for these fail on the first commit and pass on the second.

What the language now refuses

A template that nothing calls now gets the same refusals as a call site. Before, these passed load:

  • A str or bool parameter used as a value (x * tag).
  • A relation used as a value, and a dimension used as a value.
  • A column that the relation does not have (sum(x, by=lk, over=nope, into=h)).
  • over=1, and edge='nope'.
  • A list of relations in by=. It now gets the "one call reads one table" refusal, not "does not name a relation" for the first name.

Test coverage moved: a-typo-in-a-relation-list is now a-list-of-relations and asserts the resolver's message.

Tests

  • test_a_template_is_held_to_the_rules_a_call_site_is: both cases fail on the base branch and pass here.
  • test_a_formal_stands_where_a_call_site_will_bind_it: one case for each guard. I deleted each guard in turn and ran the suite:
    • The guard in _arith: 20 tests fail.
    • _edge: an-edge fails.
    • _dual: a-constraint fails.
    • The relation guard: both relation cases fail.

Gates

  • pixi run lint: green.
  • pixi run test: 1560 passed on the first commit; 1541 with tests/test_docs.py deselected on the second, where the docs dependencies were absent.
  • docs-build and compile-tex did not run: the session proxy blocks their downloads.

🤖 Generated with Claude Code

https://claude.ai/code/session_017XwKgY5wZXv1bKgkfCW2q1


Generated by Claude Code

@read-the-docs-community

read-the-docs-community Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

@FBumann
FBumann added this pull request to stack #637 September 22, 2026 20:48
… call site is

The template check was a second walker that looked at names only. It is now
the resolver, with the template's formals left bare, so a label parameter
used as a value or an unknown relation column is refused at load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017XwKgY5wZXv1bKgkfCW2q1
…typo in by= is refused beside formal columns

A formal along= beside a by= was handed to the partition as a dimension and
refused as one the relation has no key column over, so a valid template was
refused. A relation that names nothing loaded once the columns beside it were
formals, because the formals sent the call back first. The over= and by=
refusals inside a template say "or a formal of this macro" again.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015h57WkBDnpxrknuJ5zZy9F
@FBumann
FBumann removed this pull request from stack #637 September 23, 2026 11:30
@FBumann
FBumann added this pull request to stack #644 September 23, 2026 11:32
@FBumann
FBumann merged commit ffab0ff into main Sep 23, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants