mirror of
https://github.com/apple/pkl.git
synced 2026-04-25 01:38:34 +02:00
Fix empty parenthesized type unexpected error (#1323)
This commit is contained in:
committed by
GitHub
parent
bc5d675b6e
commit
ba281e8475
@@ -0,0 +1 @@
|
|||||||
|
foo: Int|()|String = "foo"
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
–– Pkl Error ––
|
||||||
|
Unexpected token `)`. Expected a type.
|
||||||
|
|
||||||
|
x | foo: Int|()|String = "foo"
|
||||||
|
^
|
||||||
|
at emptyParenthesizedTypeAnnotation (file:///$snippetsDir/input/errors/emptyParenthesizedTypeAnnotation.pkl)
|
||||||
@@ -1393,6 +1393,9 @@ public class Parser {
|
|||||||
children.add(ret);
|
children.add(ret);
|
||||||
typ = new Type.FunctionType(children, tk.span.endWith(ret.span()));
|
typ = new Type.FunctionType(children, tk.span.endWith(ret.span()));
|
||||||
} else {
|
} else {
|
||||||
|
if (children.isEmpty()) {
|
||||||
|
throw new ParserError(ErrorMessages.create("unexpectedTokenForType", ")"), end);
|
||||||
|
}
|
||||||
typ = new ParenthesizedType((Type) children.get(0), tk.span.endWith(end));
|
typ = new ParenthesizedType((Type) children.get(0), tk.span.endWith(end));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class ParserComparisonTest {
|
|||||||
"errors/moduleWithHighMinPklVersionAndParseErrors.pkl",
|
"errors/moduleWithHighMinPklVersionAndParseErrors.pkl",
|
||||||
"errors/underscore.pkl",
|
"errors/underscore.pkl",
|
||||||
"errors/shebang.pkl",
|
"errors/shebang.pkl",
|
||||||
|
"errors/emptyParenthesizedTypeAnnotation.pkl",
|
||||||
"notAUnionDefault.pkl",
|
"notAUnionDefault.pkl",
|
||||||
"multipleDefaults.pkl",
|
"multipleDefaults.pkl",
|
||||||
"modules/invalidModule1.pkl",
|
"modules/invalidModule1.pkl",
|
||||||
|
|||||||
Reference in New Issue
Block a user