Fix encoding for mapping with local members (#1152)

Fixes an issue where local members are included in
the mapping entry count.

Also: avoid re-computing Mapping.length
This commit is contained in:
Daniel Chao
2025-07-28 10:13:45 -07:00
committed by GitHub
parent a3cc2f0ea6
commit 20e7e251ec
5 changed files with 54 additions and 32 deletions

View File

@@ -13,3 +13,9 @@ res4: Mapping = new {
["bar"] = 2
}
}
// https://github.com/apple/pkl/issues/1151
res5: Mapping = new {
local self = this
["foo"] = new Dynamic { name = "foo" }
["bar"] = new Dynamic { name = self["foo"].name + "bar" }
}

View File

@@ -41,4 +41,28 @@
:
- 3
-
bar: 2
bar: 2
-
- 16
- res5
-
- 3
-
foo:
- 1
- Dynamic
- pkl:base
-
-
- 16
- name
- foo
bar:
- 1
- Dynamic
- pkl:base
-
-
- 16
- name
- foobar