Remove unused to_ir.Var.GlobalVar constructor#663
Open
mvanhorn wants to merge 1 commit intopallene-lang:masterfrom
Open
Remove unused to_ir.Var.GlobalVar constructor#663mvanhorn wants to merge 1 commit intopallene-lang:masterfrom
mvanhorn wants to merge 1 commit intopallene-lang:masterfrom
Conversation
Member
|
Is this AI generated? Please do not submit AI-generated code to pallene |
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.
Summary
Removes the
to_ir.Var.GlobalVarconstructor from theto_ir.Varunion and the twoelseif var_info._tag == "to_ir.Var.GlobalVar"arms into_ir.luathat referenced it. Per issue #662 these are residual after the rest of the global-handling rewrite.Why this matters
Issue #662 says
to_ir.Var.GlobalVaris residual code. Confirmed by reading the function that producesto_ir.Varvalues:ToIR:resolve_variable(src/pallene/to_ir.lua:237) only ever constructsto_ir.Var.LocalVar(line 255) inside its initial loop, then optionally promotes that value toto_ir.Var.Upvalue(line 288) when the declaration is captured by an enclosing function. There is no code path that constructsto_ir.Var.GlobalVar. The function assertsvaris set, so it always returns eitherLocalVarorUpvalue.That means the two
elseif var_info._tag == "to_ir.Var.GlobalVar"arms inexp_to_value(line 1066) andexp_to_assignment(line 1314) are unreachable. The first arm contains only a-- Fallthrough to defaultcomment; the second arm containsbb:append_cmd(ir.Cmd.GetGlobal(loc, dst, var_info.id))which can never execute. Theelsebranch withtagged_union.error(var_info._tag)still catches any future tag the compiler might add.Changes
src/pallene/to_ir.lua: 5 lines removed across 3 spots.GlobalVar = {"id"},removed from thedefine_union("Var", { ... })block.exp_to_value: drop theelseif ... GlobalVararm whose body is just a comment.exp_to_assignment: drop theelseif ... GlobalVararm whosebb:append_cmd(ir.Cmd.GetGlobal(...))body is unreachable.The two
elsebranches that follow each removedelseifcontinue to calltagged_union.error(var_info._tag), so any new variant would still be caught loudly at runtime.Testing
After the change,
grep -rn 'GlobalVar' src/pallene/returns no matches.I do not have a Lua / busted toolchain in this environment, so I did not run the test suite locally. The change is mechanical removal of dead code; no logic flow is altered.
Closes #662