Another implication of this change is: type constraints are stricter. Now, type annotations will check Mapping and Listing members if the annotation is executed from a constraint.
This currently does not throw, and will after this change:
import "pkl:test"
const local isBirds = (it: Listing<Bird>) -> true
birds: Listing(isBirds) = new { 1; 2; 3 }
class Bird
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/964
**Author:** [@bioball](https://github.com/bioball)
**Created:** 2/19/2025
**Status:** ✅ Merged
**Merged:** 2/19/2025
**Merged by:** [@bioball](https://github.com/bioball)
**Base:** `main` ← **Head:** `eager-constraint-checks`
---
### 📝 Commits (1)
- [`4342dc8`](https://github.com/apple/pkl/commit/4342dc8dbbf71fd4dd1a75afcf3f630f4a838409) Execute typechecks eagerly when within a constraint
### 📊 Changes
**17 files changed** (+266 additions, -63 deletions)
<details>
<summary>View changed files</summary>
📝 `pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java` (+1 -1)
📝 `pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java` (+86 -60)
📝 `pkl-core/src/main/java/org/pkl/core/ast/type/UnresolvedTypeNode.java` (+7 -2)
📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmLanguage.java` (+4 -0)
➕ `pkl-core/src/main/java/org/pkl/core/runtime/VmLocalContext.java` (+31 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input-helper/classes/MyClass.pkl` (+9 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input-helper/classes/myClass1.pkl` (+7 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/classes/constraints13.pkl` (+16 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/classes/constraints14.pkl` (+14 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/errors/constraintDetails1.pkl` (+9 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/errors/constraintDetails2.pkl` (+11 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/input/errors/constraintDetails3.pkl` (+9 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/classes/constraints13.pcf` (+1 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/classes/constraints14.pcf` (+15 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/errors/constraintDetails1.err` (+15 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/errors/constraintDetails2.err` (+16 -0)
➕ `pkl-core/src/test/files/LanguageSnippetTests/output/errors/constraintDetails3.err` (+15 -0)
</details>
### 📄 Description
This changes the language to check all types eagerly when within a type constraint.
This addresses a regression where error messages might show objects that are missing details (see https://github.com/apple/pkl/issues/918).
Another implication of this change is: type constraints are stricter. Now, type annotations will check `Mapping` and `Listing` members if the annotation is executed from a constraint.
This currently does not throw, and will after this change:
```pkl
import "pkl:test"
const local isBirds = (it: Listing<Bird>) -> true
birds: Listing(isBirds) = new { 1; 2; 3 }
class Bird
```
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/964
Author: @bioball
Created: 2/19/2025
Status: ✅ Merged
Merged: 2/19/2025
Merged by: @bioball
Base:
main← Head:eager-constraint-checks📝 Commits (1)
4342dc8Execute typechecks eagerly when within a constraint📊 Changes
17 files changed (+266 additions, -63 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java(+1 -1)📝
pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java(+86 -60)📝
pkl-core/src/main/java/org/pkl/core/ast/type/UnresolvedTypeNode.java(+7 -2)📝
pkl-core/src/main/java/org/pkl/core/runtime/VmLanguage.java(+4 -0)➕
pkl-core/src/main/java/org/pkl/core/runtime/VmLocalContext.java(+31 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input-helper/classes/MyClass.pkl(+9 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input-helper/classes/myClass1.pkl(+7 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/classes/constraints13.pkl(+16 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/classes/constraints14.pkl(+14 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/constraintDetails1.pkl(+9 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/constraintDetails2.pkl(+11 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/errors/constraintDetails3.pkl(+9 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/classes/constraints13.pcf(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/classes/constraints14.pcf(+15 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/constraintDetails1.err(+15 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/constraintDetails2.err(+16 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/errors/constraintDetails3.err(+15 -0)📄 Description
This changes the language to check all types eagerly when within a type constraint.
This addresses a regression where error messages might show objects that are missing details (see https://github.com/apple/pkl/issues/918).
Another implication of this change is: type constraints are stricter. Now, type annotations will check
MappingandListingmembers if the annotation is executed from a constraint.This currently does not throw, and will after this change:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.