Skip to content

Commit a74bf96

Browse files
authored
[J2CLOpts] Avoid erroring on imported globals in GlobalAssignmentCollector (#8023)
1 parent d5ba0b6 commit a74bf96

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/passes/J2CLOpts.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ class GlobalAssignmentCollector
8888
: assignmentCounts(assignmentCounts) {}
8989

9090
void visitGlobal(Global* curr) {
91+
// Ignore imported globals, e.g., JS prototypes.
92+
if (curr->imported()) {
93+
return;
94+
}
9195
if (isInitialValue(curr->init)) {
9296
return;
9397
}

test/lit/passes/j2cl.wast

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,10 @@
351351
)
352352
)
353353
)
354+
355+
;; Imported globals are ignored
356+
(module
357+
;; CHECK: (import "a" "b" (global $a.b (ref extern)))
358+
(import "a" "b" (global $a.b (ref extern)))
359+
)
360+

0 commit comments

Comments
 (0)