Skip to content

Commit

Permalink
fix(core): fix bug caused by iterating over empty ast object
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman committed Jan 20, 2023
1 parent 2e8b7cd commit 2e41b30
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-crews-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chugsplash/core': patch
---

Fix bug caused by iterating over empty AST node object
10 changes: 6 additions & 4 deletions packages/core/src/languages/solidity/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,12 @@ export const mapContractAstIdsToSourceNames = (
outputSources: CompilerOutputSources
): { [astId: number]: string } => {
const contractAstIdsToSourceNames: { [astId: number]: string } = {}
for (const [sourceName, { ast }] of Object.entries(outputSources) as any) {
for (const node of ast.nodes) {
if (node.name !== undefined) {
contractAstIdsToSourceNames[node.id] = sourceName
for (const [sourceName, { ast }] of Object.entries(outputSources)) {
if (ast.nodes !== undefined) {
for (const node of ast.nodes) {
if (node.name !== undefined) {
contractAstIdsToSourceNames[node.id] = sourceName
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/languages/solidity/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export interface CompilerOutputSource {
ast: {
id: number
exportedSymbols: { [contractName: string]: number[] }
nodes?: any
}
}

Expand Down

0 comments on commit 2e41b30

Please sign in to comment.