Skip to content

Conversation

@xrchz
Copy link
Member

@xrchz xrchz commented Jan 9, 2026

Previously, the translator renamed all variables using generic patterns like v1, v2, v3 (or x1, x2, x3), discarding the original names from the shallow embedding. This made generated code harder to read and debug.

Now variable names include the original name as a suffix, producing names like v1_foo, v2_bar. For pattern-matched arguments that aren't simple variables, the old vN naming is retained as a fallback.

Addresses issue #12.

Previously, the translator renamed all variables using generic patterns
like v1, v2, v3 (or x1, x2, x3), discarding the original names from the
shallow embedding. This made generated code harder to read and debug.

Now variable names include the original name as a suffix, producing
names like v1_foo, v2_bar. For pattern-matched arguments that aren't
simple variables, the old vN naming is retained as a fallback.

Addresses issue #12.

Co-Authored-By: Claude <[email protected]>
@xrchz xrchz requested a review from myreen January 9, 2026 16:49
xrchz and others added 2 commits January 9, 2026 17:10
The previous change to preserve variable names was incorrectly
preserving names from intermediate renaming passes (using the
" variable " prefix with spaces). This produced malformed names
like "v1_ variable 1_foo".

Fix by detecting names containing spaces and not appending them,
since real source variable names cannot contain spaces.

Co-Authored-By: Claude <[email protected]>
Copy link
Contributor

@myreen myreen left a comment

Choose a reason for hiding this comment

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

It's a bit risky to change a name such as x' to v4_x' because the translator eagerly removes trailing primes. This means that it can in some subterm change v4_x' to v4_x which might not match what's in a different subterm.

A safer option would be to make the new names be v4_x'_ or some other format that doesn't have the original name directly as a suffix.

@xrchz xrchz merged commit 0978a59 into master Jan 13, 2026
1 check failed
@xrchz xrchz deleted the vname branch January 13, 2026 07:10
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.

3 participants