Fix crash due to parse error in module header (#1112)

This commit is contained in:
Jen Basch authored and GitHub committed 2025-07-01 10:05:16 +02:00
1 parent f1388ffb2f
commit dbf57280ba
4 files changed
+10 -1

No files matched your search

@@ -33,7 +33,8 @@ public final class Module extends AbstractNode {
public @Nullable ModuleDecl getDecl() {
assert children != null;
return (ModuleDecl) children.get(0);
// children can be empty when there was a parse error
return children.isEmpty() ? null : (ModuleDecl) children.get(0);
}
public List<ImportClause> getImports() {
@@ -91,6 +91,7 @@ class ParserComparisonTest : ParserComparisonTestInterface {
"errors/underscore.pkl",
"notAUnionDefault.pkl",
"multipleDefaults.pkl",
"modules/invalidModule1.pkl",
)
private val regexExceptions =