Wrong source location when spreading amended object
- Dominant language
- Java
- Stars
- 11.5k
- Forks
- 402
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 20
Description
```
l = new Listing { "foo" }
l2 = (l) {
[0] = "bar"
}
l3 = new Listing {
...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 {
^^^
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.
Contributor guide
Research direction
Start with VmObject.iterateMemberValues() and reproduce the Listing example from the issue. Trace how the amended value "bar" and its source location are carried through iteration; done when the error points to the amended value's location rather than the original "foo" location, including other affected iteration paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100