Reserve declared names against generated tN/TN identifiers (#8) - #156
Open
petlenz wants to merge 1 commit into
Open
Reserve declared names against generated tN/TN identifiers (#8)#156petlenz wants to merge 1 commit into
petlenz wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #8.
User symbols named
t0/t1/T0/T1collided with generated CSE temporaries and template parameters, producing uncompilable emitted code (parameter redeclaration / template-parameter shadowing — reproduced on the issue).CodeGenContextgainsreserve_name();fresh_name()skips reserved candidates. Reservations survivereset()(they describe the surrounding function's identifiers, like the temp counter reset already preserves) and clear onfull_reset().detail::emission_reserved_names(RecipeView)— all symbol names (incl._oldrows), output names +_outvariants, tangent names +_out— seeded inCodeEmitPass::run; the coupled-Newtonreserved_idsblock now reuses the same helper.render_compute_functionpicks template-parameter names from the same collision check, single-sourced between thetemplate<...>list and the signature.Skip-on-collision-only: with no collision the emitted text is byte-identical — all 321 pre-existing tests pass unmodified (many pin
t0/t1/T0), plus an explicitGeneratedNamingUnchangedWithoutCollisionguard. Real regression gate: recipeReservedNamesCheck(inputst0,t1, tensor inputT0, tensor outputT1) is generated, COMPILED, and numerically checked in the compile-check driver — emitstemplate <typename T2, typename T3>with temps starting att2.Rebased onto current main. gcc-14 Debug (-Werror): ctest 327/327.
Note: when PR #124 merges, its
newton_reserved_idshelper and this PR'semission_reserved_namescover adjacent concerns — trivial merge either order; unifying them is a two-line follow-up.