Fix crash due to parse error in module header (#1112)
This commit is contained in:
1 parent
f1388ffb2f
commit
dbf57280ba
4 files changed
+10
-1
No files matched your search
@@ -0,0 +1 @@
|
||||
module "DoNotQuote"
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
–– Pkl Error ––
|
||||
Unexpected token `"`. Expected `identifier`.
|
||||
|
||||
x | module "DoNotQuote"
|
||||
^
|
||||
at invalidModule1 (file:///$snippetsDir/input/modules/invalidModule1.pkl)
|
||||
@@ -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 =
|
||||
|
||||
Reference in new issue
Block a user