Skip to content

Commit 725bccb

Browse files
rishipalcopybara-github
authored andcommitted
Add TODO comments in bug-prone ASTFactory methods that create name nodes
ASTFactory create* methods depend on lifeCycleStage.isNormalized() and "$jscomp" prefix to decide name node constantess. Callsites would get a constant name depending on whether they created before or after normalize. PiperOrigin-RevId: 602730752
1 parent a5f1536 commit 725bccb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/com/google/javascript/jscomp/AstFactory.java

+4
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,9 @@ Node createName(String name, Type type) {
577577
if (lifeCycleStage.isNormalized() && name.startsWith("$jscomp")) {
578578
// $jscomp will always be a constant and needs to be marked that way to satisfy
579579
// the normalization invariants.
580+
// TODO: b/322009741 - Stop depending on lifeCycleStage.isNormalized() and "$jscomp" prefix to
581+
// decide constness. The callers must explicitly use `createConstantName` is they need a NAME
582+
// node that's set with IS_CONSTANT_NAME prop.
580583
result.putBooleanProp(Node.IS_CONSTANT_NAME, true);
581584
}
582585
return result;
@@ -587,6 +590,7 @@ Node createConstantName(String name, Type type) {
587590
Node result = IR.name(name);
588591
setJSTypeOrColor(type, result);
589592
if (lifeCycleStage.isNormalized()) {
593+
// TODO: b/322009741 - Stop depending on lifeCycleStage.isNormalized() to decide constness
590594
result.putBooleanProp(Node.IS_CONSTANT_NAME, true);
591595
}
592596
return result;

0 commit comments

Comments
 (0)