Wrong source location when spreading amended object #242

Open
opened 2025-12-30 01:22:37 +01:00 by adam · 3 comments
Owner

Originally created by @odenix on GitHub (Nov 3, 2024).

l = new Listing { "foo" }

l2 = (l) {
  [0] = "bar"
}

l3 = new Listing<Int> {
  ...l2
}

The error message correctly complains about "bar" but shows the source location of "foo":

–– Pkl Error ––
Expected value of type `Int`, but got type `String`.
Value: "bar"

7 | l3 = new Listing<Int> {
                     ^^^
at test#l3 (file:///D:/pkl/test.pkl, line 7)

1 | l = new Listing { "foo" }
                      ^^^^^
at test#l[#1] (file:///D:/pkl/test.pkl, line 1)

This issue is caused by a fundamental flaw in how VmObject.iterateMemberValues() works. The same issue likely exists in other places.

I'm working towards a fix that offers better ways to iterate over VmObject. (It's how I discovered this problem.)

PS: The blue colored line numbers 7 | and 1 | are difficult to read on black background.

Originally created by @odenix on GitHub (Nov 3, 2024). ``` l = new Listing { "foo" } l2 = (l) { [0] = "bar" } l3 = new Listing<Int> { ...l2 } ``` The error message correctly complains about "bar" but shows the source location of "foo": ``` –– Pkl Error –– Expected value of type `Int`, but got type `String`. Value: "bar" 7 | l3 = new Listing<Int> { ^^^ at test#l3 (file:///D:/pkl/test.pkl, line 7) 1 | l = new Listing { "foo" } ^^^^^ at test#l[#1] (file:///D:/pkl/test.pkl, line 1) ``` This issue is caused by a fundamental flaw in how `VmObject.iterateMemberValues()` works. The same issue likely exists in other places. I'm working towards a fix that offers better ways to iterate over `VmObject`. (It's how I discovered this problem.) PS: The blue colored line numbers `7 |` and `1 |` are difficult to read on black background.
adam added the bug label 2025-12-30 01:22:37 +01:00
Author
Owner

@bioball commented on GitHub (Nov 4, 2024):

PS: The blue colored line numbers 7 | and 1 | are difficult to read on black background.

Hm, it doesn't look too bad for me. But, hard to predict how every terminal renders this. Can you send a screenshot?

@bioball commented on GitHub (Nov 4, 2024): > PS: The blue colored line numbers 7 | and 1 | are difficult to read on black background. Hm, it doesn't look too bad for me. But, hard to predict how every terminal renders this. Can you send a screenshot?
Author
Owner

@odenix commented on GitHub (Nov 4, 2024):

I can barely read them.

Screenshot 2024-11-04 001340 - Copy

@odenix commented on GitHub (Nov 4, 2024): I can barely read them. ![Screenshot 2024-11-04 001340 - Copy](https://github.com/user-attachments/assets/7251f785-fcf2-4cac-9552-f5811e8b2268)
Author
Owner

@odenix commented on GitHub (Nov 11, 2024):

I have a PR ready. I'll send it once fewer PRs are in flight.

@odenix commented on GitHub (Nov 11, 2024): I have a PR ready. I'll send it once fewer PRs are in flight.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#242