Skip to content

remove specialization masks in safe.ts - #1353

Merged
Lorenzobattistela merged 2 commits into
bendlang:mainfrom
toprameen:simplify-specialization-prefix
Oct 6, 2026
Merged

Lorenzobattistela merged 2 commits into
bendlang:mainfrom
toprameen:simplify-specialization-prefix

Conversation

@toprameen

@toprameen toprameen commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Replace spec_of’s boolean arrays with declaration arity and the template prefix count. Checked templates have a contiguous leading prefix; datatypes and term heads keep prefix zero.

Local checks: repository gate and whitespace check pass. Exact BendTT text and out-of-scope results match on 331 checked books, including a focused fixture, with four repeated-call comparisons and 15 direct boundary checks. All 14 local BendTT verdict comparisons match the baseline; 13 CLI verdicts pass and five parser diagnostic pins match.

@toprameen
toprameen marked this pull request as ready for review October 5, 2026 19:39
@Lorenzobattistela Lorenzobattistela self-assigned this Oct 6, 2026

@Lorenzobattistela Lorenzobattistela left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a clean follow-up to #1203. Since #1203, spec_of was always a leading prefix of tld.x trues, so storing the count instead of the array is exact. It relies on two things the parser guarantees: a ~ only comes on leading clauses or binders, and a def that fills a law has tele.length >= law.x, so x <= n always holds.

I checked it merged onto main 53fc961, using main's own gate files:

  • repo 50/50, ping 47/47, test 1577/1577
  • perf 123/124, the same as main (a first run showed 120/124 from node contention; the rerun matches)
  • gates/safe.ts tests: the table is byte-identical to main's (1018 agree, 0 timeouts; the one false reject, agree_32, is already on main)
  • -o: every tests/*/*.bend emitted on both trees; all 1577 exit codes match and all 1090 .bendtt files are byte-identical

So the change has no effect on output. Two small nits, neither blocking:

  1. sp is a boolean[] on main and a count after this PR (in args and in group_emit's rest). Code that still does sp[j] on a number gets undefined with no type error, and every parameter silently counts as unspecialized. A name like nx would make
  2. The comment on the deleted spec_of was the only place safe.ts said which parameters get specialized. The new code also depends on those parameters one-line comment at root_cols or args(e.g. "a def's first x parameters, its ~ ones, are specialized") would keep that rule written down.

@toprameen
toprameen force-pushed the simplify-specialization-prefix branch from b3da467 to 4649752 Compare October 6, 2026 17:52
@Lorenzobattistela
Lorenzobattistela merged commit 7192eff into bendlang:main Oct 6, 2026
1 check 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