local values referencing this inside Mappings are included in entry count when binary encoded #324

Closed
opened 2025-12-30 01:23:32 +01:00 by adam · 1 comment
Owner

Originally created by @sin-ack on GitHub (Jul 25, 2025).

Reproduced on 0.29.0.

Reproducer:

foo = new Mapping {
    local self = this
    ["foo"] = new Dynamic { name = "foo" }
    ["bar"] = new Dynamic { name = self["foo"].name + "bar" }
}

Evaluate foo with something that communicates with pkl server. The returned value will be (in JSON repr):

[3, (map size: 3) {"foo": [0x3, (map size: 1) {"name": "foo"}], "bar": [3, (map size: 1) {"name": "foobar"}]}]

Notice that it returns a map of size 3. However, the MessagePack data only contains 2 items. This causes a decode error on my side.

Originally created by @sin-ack on GitHub (Jul 25, 2025). Reproduced on 0.29.0. Reproducer: ```pkl foo = new Mapping { local self = this ["foo"] = new Dynamic { name = "foo" } ["bar"] = new Dynamic { name = self["foo"].name + "bar" } } ``` Evaluate `foo` with something that communicates with `pkl server`. The returned value will be (in JSON repr): ```js [3, (map size: 3) {"foo": [0x3, (map size: 1) {"name": "foo"}], "bar": [3, (map size: 1) {"name": "foobar"}]}] ``` Notice that it returns a map of size 3. However, the MessagePack data only contains 2 items. This causes a decode error on my side.
adam closed this issue 2025-12-30 01:23:32 +01:00
Author
Owner

@bioball commented on GitHub (Jul 25, 2025):

Thanks for the easily reproducible bug report!

@bioball commented on GitHub (Jul 25, 2025): Thanks for the easily reproducible bug report!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#324