mirror of
https://github.com/apple/pkl.git
synced 2026-03-20 16:23:57 +01:00
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:
@@ -221,7 +221,7 @@ internal class BinaryEvaluator(
|
||||
override fun visitMapping(value: VmMapping) {
|
||||
packer.packArrayHeader(2)
|
||||
packer.packInt(CODE_MAPPING.toInt())
|
||||
packer.packMapHeader(value.entryCount)
|
||||
packer.packMapHeader(value.length.toInt())
|
||||
value.iterateAlreadyForcedMemberValues { key, _, memberValue ->
|
||||
visit(key)
|
||||
visit(memberValue)
|
||||
|
||||
@@ -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" }
|
||||
}
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user