Failed type constraint error messages do not show forced members #271

Closed
opened 2025-12-30 01:23:03 +01:00 by adam · 3 comments
Owner

Originally created by @bioball on GitHub (Jan 30, 2025).

This is a regression.

This snippet:

foo: Listing(firstOneIsSandy) = new {
  new Bird { name = "Bob" }
  new Bird { name = "Bob" }
}

firstOneIsSandy = (it: Listing<Bird>) -> it[0].name == "Sandy"

class Bird { name: String }

Produces the following error message:

–– Pkl Error ––
Type constraint `firstOneIsSandy` violated.
Value: new Listing { ?; ? }

1 | foo: Listing(firstOneIsSandy) = new {
                 ^^^^^^^^^^^^^^^

In Pkl 0.26, we get more details:

–– Pkl Error ––
Type constraint `firstOneIsSandy` violated.
Value: new Listing { new Bird { name = "Bob" }; new Bird { name = ? } }

1 | foo: Listing(firstOneIsSandy) = new {
                 ^^^^^^^^^^^^^^^
Originally created by @bioball on GitHub (Jan 30, 2025). This is a regression. This snippet: ```pkl foo: Listing(firstOneIsSandy) = new { new Bird { name = "Bob" } new Bird { name = "Bob" } } firstOneIsSandy = (it: Listing<Bird>) -> it[0].name == "Sandy" class Bird { name: String } ``` Produces the following error message: ``` –– Pkl Error –– Type constraint `firstOneIsSandy` violated. Value: new Listing { ?; ? } 1 | foo: Listing(firstOneIsSandy) = new { ^^^^^^^^^^^^^^^ ``` In Pkl 0.26, we get more details: ``` –– Pkl Error –– Type constraint `firstOneIsSandy` violated. Value: new Listing { new Bird { name = "Bob" }; new Bird { name = ? } } 1 | foo: Listing(firstOneIsSandy) = new { ^^^^^^^^^^^^^^^ ```
adam added the bug label 2025-12-30 01:23:03 +01:00
adam closed this issue 2025-12-30 01:23:04 +01:00
Author
Owner

@bioball commented on GitHub (Jan 30, 2025):

This has to do with the listing/mapping typecheck changes.

Removing the type annotation on the lambda parameter gives us the same error message as in Pkl 0.26.

 foo: Listing(firstOneIsSandy) = new {
   new Bird { name = "Bob" }
   new Bird { name = "Bob" }
 }
 
-firstOneIsSandy = (it: Listing<Bird>) -> it[0].name == "Sandy"
+firstOneIsSandy = (it) -> it[0].name == "Sandy"
 
 class Bird { name: String }

Perhaps the correct behavior here is to execute eager typechecks when executing a constraint node.

@bioball commented on GitHub (Jan 30, 2025): This has to do with the listing/mapping typecheck changes. Removing the type annotation on the lambda parameter gives us the same error message as in Pkl 0.26. ```diff foo: Listing(firstOneIsSandy) = new { new Bird { name = "Bob" } new Bird { name = "Bob" } } -firstOneIsSandy = (it: Listing<Bird>) -> it[0].name == "Sandy" +firstOneIsSandy = (it) -> it[0].name == "Sandy" class Bird { name: String } ``` Perhaps the correct behavior here is to execute eager typechecks when executing a constraint node.
Author
Owner

@bioball commented on GitHub (Feb 20, 2025):

Closed by #964

@bioball commented on GitHub (Feb 20, 2025): Closed by #964
Author
Owner

@cceneag commented on GitHub (Jun 19, 2025):

👍

@cceneag commented on GitHub (Jun 19, 2025): 👍
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#271