Compiler emits dead instructions (unreachable AccessOperation arm, dead JumpIfUndefined after required loads) #25
Labels
No labels
automated-🤖
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Hemera/nomo#25
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two pieces of the compiler are unreachable dead code that make the required/safe-access logic harder to follow:
The
AccessOperationarm ininner_access_op(src/compiler/mod.rs:613-629), which is the only place that emitsFailIfUndefined(it checksTokenOperator::DotvsQuestionMark). The parser never produces anAccessOperationon a Dot's rhs (an infix rhs is always a plain operand), so this arm never runs. This is directly related to the missing required-access enforcement (see issue "?operator only guards the head of an access chain").JumpIfUndefinedis emitted right after aLoadFromContextToSlotwithfail_on_not_found: true(e.g.tests/cases/deep_access.3-instructions.snap, instructions 91-105). Afail: trueload returns an error on missing, neverUndefined, so that jump can never fire.Suggest removing the dead arm (and emitting
FailIfUndefinedfrom theVariableAccessarm instead) and skipping the redundantJumpIfUndefinedwhen the base load is required.