Skip to content

Type switch scrutinee bindings by their enumeration type - #233

Draft
nikswamy wants to merge 1 commit into
mainfrom
nswamy/pal-pr19-switch-enum-scrutinee
Draft

Type switch scrutinee bindings by their enumeration type#233
nikswamy wants to merge 1 commit into
mainfrom
nswamy/pal-pr19-switch-enum-scrutinee

Conversation

@nikswamy

Copy link
Copy Markdown
Contributor

Part of the upstreaming of nswamy/pal-c-project-integration (PR19 of 35 PRs) — see PR_PLAN.md on that branch for the whole plan and the dependency graph.

Base: main. Depends on nothing; reviewable on its own.

Clang promotes a switch condition, and an enumeration modeled by its underlying integer
type makes that promotion the identity, which the rvalue translation elides — but the
scrutinee binding was still annotated with the promoted type, so the declared type and the
bound value were syntactically distinct and Pulse's dereference tactic, which compares
syntactically, rejected the binding. Other promotions are genuine casts and keep their
promoted type.

Commits

  • Type switch scrutinee bindings by their enumeration type

Testing

No test directory of its own — this is an enabler whose effect shows up in another PR's fixture, a pulse/ library lemma, or a tests-todo reproducer. Verified with a full make test -j8 (1372 modules, 0 errors) to confirm it regresses nothing.

Clang applies the integral promotions to a switch condition, so the
translated condition carries the promoted integer type. An enumeration is
modeled by its underlying integer type, which makes that promotion the
identity, so the rvalue translation elides it. The scrutinee binding was
still annotated with the promoted type, leaving the declared type and the
bound value syntactically distinct. The Pulse dereference tactic compares
types syntactically and rejected the binding.

Annotate the binding with the enumeration's own type when the unpromoted
condition is an enumeration. Other promotions remain genuine casts that the
rvalue translation preserves, so their promoted type is still correct.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 981f7d3c-6a91-47ad-84d7-7aadf747123d
(cherry picked from commit 588982d)
@gebner

gebner commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

!diff

@github-actions

Copy link
Copy Markdown

Generated F* output diff

Effect of this pull request on the F* code pal generates for the test suite (f9d4dd29a59bcd).

✅ The generated output is unchanged.

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