Skip to content

Commit d5ed7e5

Browse files
Adjective-ObjectMax Huang-Hobbs
andauthored
Avoid infinite loops in export * from expansion (#118)
- Avoids infinite loop while expanding unresolved external import - Avoids infinite loop while expanding cyclical imports - Adds maximum caps to all frontier traversals in graph generation and export * expansion --------- Co-authored-by: Max Huang-Hobbs <[email protected]>
1 parent dd8dd78 commit d5ed7e5

File tree

4 files changed

+443
-18
lines changed

4 files changed

+443
-18
lines changed

.devcontainer/default/container/.gitconfig

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
[column]
2+
ui = auto
3+
[branch]
4+
sort = -committerdate
5+
[tag]
6+
sort = version:refname
7+
[init]
8+
defaultBranch = main
9+
[diff]
10+
algorithm = histogram
11+
colorMoved = plain
12+
mnemonicPrefix = true
13+
renames = true
14+
[push]
15+
default = simple
16+
autoSetupRemote = true
17+
followTags = true
18+
[fetch]
19+
prune = true
20+
pruneTags = true
21+
all = true
22+
23+
[help]
24+
autocorrect = prompt
25+
[commit]
26+
verbose = true
27+
[rerere]
28+
enabled = true
29+
autoupdate = true
30+
[rebase]
31+
autoSquash = true
32+
autoStash = true
33+
updateRefs = true
34+
135
[alias]
236
lol = log --oneline --graph
337
lola = log --oneline --graph --all
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix infinite loops in export * expansion",
4+
"packageName": "@good-fences/api",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

crates/unused_finder/src/parse/data.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,54 @@ impl ResolvedImportExportInfo {
205205
.chain(re_exports)
206206
.chain(executed_paths)
207207
}
208+
209+
/// Test helper that gets a copy of this ImportExportInfo with all spans
210+
/// zeroed.
211+
pub fn with_zeroed_spans(&self) -> Self {
212+
let exported_ids = self
213+
.exported_ids
214+
.iter()
215+
.map(|(symbol, meta)| {
216+
(
217+
symbol.clone(),
218+
ExportedSymbolMetadata {
219+
span: Span::default(),
220+
..meta.clone()
221+
},
222+
)
223+
})
224+
.collect();
225+
let export_from_symbols = self
226+
.export_from_symbols
227+
.iter()
228+
.map(|(path, symbols)| {
229+
(
230+
path.clone(),
231+
symbols
232+
.iter()
233+
.map(|(symbol, meta)| {
234+
(
235+
symbol.clone(),
236+
ExportedSymbolMetadata {
237+
span: Span::default(),
238+
..meta.clone()
239+
},
240+
)
241+
})
242+
.collect(),
243+
)
244+
})
245+
.collect();
246+
247+
Self {
248+
exported_ids,
249+
export_from_symbols,
250+
imported_symbols: self.imported_symbols.clone(),
251+
require_paths: self.require_paths.clone(),
252+
imported_paths: self.imported_paths.clone(),
253+
executed_paths: self.executed_paths.clone(),
254+
}
255+
}
208256
}
209257

210258
#[derive(Debug, Eq, PartialEq, Clone, Hash, Default)]

0 commit comments

Comments
 (0)