Skip to content

Commit 994d3f8

Browse files
Merge branch 'main' into 01-29-fix_6036
2 parents ea00d21 + cd64976 commit 994d3f8

File tree

4 files changed

+3
-14
lines changed

4 files changed

+3
-14
lines changed

crates/rolldown/src/ast_scanner/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,16 +523,11 @@ impl<'me, 'ast: 'me> AstScanner<'me, 'ast> {
523523
fn add_local_export(&mut self, export_name: &str, local: SymbolId, span: Span) {
524524
let symbol_ref: SymbolRef = (self.immutable_ctx.idx, local).into();
525525

526-
let is_const = self.result.symbol_ref_db.scoping().symbol_flags(local).is_const_variable();
527-
528526
// If there is any write reference to the local variable, it is reassigned.
529527
let is_reassigned =
530528
self.result.symbol_ref_db.get_resolved_references(local).any(Reference::is_write);
531529

532530
let ref_flags = symbol_ref.flags_mut(&mut self.result.symbol_ref_db);
533-
if is_const {
534-
ref_flags.insert(SymbolRefFlags::IsConst);
535-
}
536531
if !is_reassigned {
537532
ref_flags.insert(SymbolRefFlags::IsNotReassigned);
538533
}

crates/rolldown/src/utils/chunk/render_chunk_exports.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ fn must_keep_live_binding(
368368
) -> bool {
369369
let canonical_ref = symbol_db.canonical_ref_for(export_ref);
370370

371-
if canonical_ref.is_declared_by_const(symbol_db).unwrap_or(false) {
372-
// For unknown case, we consider it as not declared by `const`.
371+
if canonical_ref.is_declared_by_const(symbol_db) {
373372
return false;
374373
}
375374

crates/rolldown_common/src/types/symbol_ref.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ impl SymbolRef {
3737
db.local_db_mut(self.owner).flags.entry(self.symbol).or_default()
3838
}
3939

40-
// `None` means we don't know if it's declared by `const`.
41-
pub fn is_declared_by_const(&self, db: &SymbolRefDb) -> Option<bool> {
42-
let flags = self.flags(db)?;
43-
// Not having this flag means we don't know if it's declared by `const` instead of it's not declared by `const`.
44-
flags.contains(SymbolRefFlags::IsConst).then_some(true)
40+
pub fn is_declared_by_const(&self, db: &SymbolRefDb) -> bool {
41+
db.local_db(self.owner).ast_scopes.scoping().symbol_flags(self.symbol).is_const_variable()
4542
}
4643

4744
/// `None` means we don't know if it gets reassigned.

crates/rolldown_common/src/types/symbol_ref_db.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ bitflags::bitflags! {
2626
#[derive(Debug, Default, Clone, Copy)]
2727
pub struct SymbolRefFlags: u8 {
2828
const IsNotReassigned = 1;
29-
/// If this symbol is declared by `const`. Eg. `const a = 1;`
30-
const IsConst = 1 << 1;
3129
const MustStartWithCapitalLetterForJSX = 1 << 2;
3230
/// If the SymbolRef points to a side-effects-free function
3331
const SideEffectsFreeFunction = 1 << 3;

0 commit comments

Comments
 (0)