Skip to content

Reserve opaque template names across validation order - #1006

Closed
sadasant wants to merge 1 commit into
bendlang:mainfrom
sadasant:fix/994-namespace-capture
Closed

sadasant wants to merge 1 commit into
bendlang:mainfrom
sadasant:fix/994-namespace-capture

Conversation

@sadasant

Copy link
Copy Markdown

The checker accepts a closed inhabitant of Empty when a later declaration reuses the generated name of an opaque ~ template binder. Validation deliberately hides later declarations, so the existing freshness check sees only the partial TLD table; after validation, the checked body's Ref can resolve to the later declaration.

Reserve every parsed TLD and constructor name before ordered validation, and check generated opaque names against that complete set. Ordered replay still hides future declarations for ordinary forward-reference checking. The regression suite includes the reported constructor/TLD capture and a constructor declared after a valid template fill.

Closes #994.

Validation:

  • Current unpatched upstream accepts the reported reproducer with All terms check.; this branch rejects it with a fresh ~ binder name.
  • Local check/interpret harness: 1,416 of 1,429 tests matched exactly. The other 13 are TCP/UDP tests blocked by this sandbox's socket permissions (Operation not permitted / no free port).
  • bend2/base.bend --check-only passes with only its expected two unsafe/foreign notices.
  • TypeScript produces the same four pre-existing diagnostics on upstream and this branch; this change adds none.
  • gates/repo.ts could not run locally because its external ttok executable is unavailable.

@nicolas-abril

Copy link
Copy Markdown
Collaborator

Thank you for this, and for the clear write-up and the regression cases. I'm closing it in favour of #1042, which fixes #994 at the source instead.

#1042 limits declared names to words joined by dots and import paths to plain segments, so a ~ name exists only when the checker or compiler mints it. A later def, constructor or file can no longer spell k~B, whatever order validation runs in. I ran both of your tests on #1042: each is now refused while loading, at the import of law.k~B.bend, before any checking happens. With that, reserving names ahead of validation is no longer needed.

If you think this is a mistake and your change should still be merged, feel free to reopen and leave a comment.

--

Note: this comment was written by an AI after it tested the PR for me and I reviewed the findings. If anything here is wrong, reply and I will review it myself.

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.

A constructor name reused by a later definition bypasses #905 and admits Empty

2 participants