Skip to content

EMPTY_ARRAY used for identity checks, but multiple are declared in core #28229

@filipesilva

Description

@filipesilva

🐞 bug report

Affected Package

The issue is caused by package @angular/core

Is this a regression?

Unsure.

Description

packages/core/src/render3/empty.ts states:

/**
 * This file contains reuseable "empty" symbols that can be used as default return values
 * in different parts of the rendering code. Because the same symbols are returned, this
 * allows for identity checks against these values to be consistently used by the framework
 * code.
 */
export var EMPTY_OBJ = {};
export var EMPTY_ARRAY = [];

But at the moment there are 6 instances of const EMPTY_ARRAY in //packages/core/src, 3 of which are exported.

Since it's supposedly being used for identify checks, it probably should either:

  • use the same one everywhere
  • if they mean different things, name them differently

If they should be the same one, some identity checks are likely incorrect at the moment.

🔬 Minimal Reproduction

I don't think this is a runtime problem. It's just something in the sourcecode.

🔥 Exception or Error

🌍 Your Environment

Angular Version:

 master in github



Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5The team acknowledges the request but does not plan to address it, it remains open for discussionarea: coreIssues related to the framework runtimerefactoringIssue that involves refactoring or code-cleanupstate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions