Skip to content

Tree-shaking incorrectly eliminates optional access to a shared array element  #5343

@gebsh

Description

@gebsh

Rollup Version

4.9.5

Operating System (or Browser)

macOS Sonoma 14.2.1 / Firefox 121.0.1

Node Version (if applicable)

21.6.0

Link To Reproduction

REPL link

Expected Behaviour

state.foo?.(); line should not be eliminated by tree-shaking.

Actual Behaviour

state.foo?.(); is not present in the bundle output.

I assume this is caused by the fact that the shared object is accessed via state not via stack[0] or stack.at(-1). Changing to any of these two correctly preserves the line in the output.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions