Skip to content

Commit 6110618

Browse files
committed
check for nil
1 parent d82156d commit 6110618

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/compiler/fileloader.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,16 @@ func getModuleLiteralImportKind(node *ast.StringLiteralLike) *string {
790790
}
791791

792792
if ast.IsImportDeclaration(parent) || ast.IsExportDeclaration(parent) {
793-
var elements []*ast.Node
793+
var attrs *ast.ImportAttributesNode
794794
if ast.IsImportDeclaration(parent) {
795-
elements = parent.AsImportDeclaration().Attributes.AsImportAttributes().Attributes.Nodes
795+
attrs = parent.AsImportDeclaration().Attributes
796796
} else {
797-
elements = parent.AsExportDeclaration().Attributes.AsImportAttributes().Attributes.Nodes
797+
attrs = parent.AsExportDeclaration().Attributes
798798
}
799+
if attrs == nil {
800+
return nil
801+
}
802+
elements := attrs.AsImportAttributes().Attributes.Nodes
799803
if elements == nil {
800804
return nil
801805
}

0 commit comments

Comments
 (0)