mirror of
https://github.com/apple/pkl.git
synced 2026-05-21 22:36:57 +02:00
Fix crash due to parse error in module header (#1112)
This commit is contained in:
@@ -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