mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 14:20:35 +01:00
[PR #1323] [MERGED] Fix empty parethesized type unexpected error #1018
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/1323
Author: @spyoungtech
Created: 11/18/2025
Status: ✅ Merged
Merged: 11/18/2025
Merged by: @stackoverflow
Base:
main← Head:fix-empty-parethesized-type-error📝 Commits (4)
3c635a6throw detailed error when parenthesized type is empty6c69fa6add test for empty parenthesized type annotation5e45514add new test to exceptions5dde0e5pass error location instead of backtracking📊 Changes
4 files changed (+11 additions, -0 deletions)
View changed files
➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/emptyParenthesizedTypeAnnotation.pkl(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/emptyParenthesizedTypeAnnotation.err(+6 -0)📝
pkl-parser/src/main/java/org/pkl/parser/Parser.java(+3 -0)📝
pkl-parser/src/test/kotlin/org/pkl/parser/ParserComparisonTest.kt(+1 -0)📄 Description
When a parethesized type atom is empty, an unexpected error occurs (due to an
IndexOutOfBoundsException)For example take
t.pklas a reproducible example:Unexpected behavior: an unspecified error message is shown without source information:
Expected behavior: the parser gracefully throws an error that provides details of the error in the source file.
This PR addresses this issue by first checking if the
childrenarray is empty, and if it is, throwing a parser error when it is empty.After applying the fix proposed here, the expected behavior occurs:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.