mirror of
https://github.com/apple/pkl.git
synced 2026-04-18 06:29:45 +02:00
Fix length of listings with computed index (#797)
Motivation:
The following expression evaluates to 2 instead of 1:
new Listing { "value" } { [0 + 0] = "override" }.length
Changes:
- fix length computation in EntriesLiteralNode
- improve `api/listing` tests
- make snippet test failures diffable in IntelliJ
Result:
- fixes https://github.com/apple/pkl/issues/780
- improved dev experience in IntelliJ
This commit is contained in:
@@ -43,15 +43,15 @@ public abstract class EntriesLiteralNode extends SpecializedObjectLiteralNode {
|
||||
@Children private final ExpressionNode[] keyNodes;
|
||||
private final ObjectMember[] values;
|
||||
|
||||
public EntriesLiteralNode(
|
||||
protected EntriesLiteralNode(
|
||||
SourceSection sourceSection,
|
||||
VmLanguage language,
|
||||
// contains local properties and default property (if present)
|
||||
// does *not* contain entries with constant keys to maintain definition order of entries
|
||||
String qualifiedScopeName,
|
||||
boolean isCustomThisScope,
|
||||
@Nullable FrameDescriptor parametersDescriptor,
|
||||
UnresolvedTypeNode[] parameterTypes,
|
||||
// contains local properties and default property (if present)
|
||||
// does *not* contain entries with constant keys to maintain definition order of entries
|
||||
UnmodifiableEconomicMap<Object, ObjectMember> members,
|
||||
ExpressionNode[] keyNodes,
|
||||
ObjectMember[] values) {
|
||||
@@ -103,7 +103,8 @@ public abstract class EntriesLiteralNode extends SpecializedObjectLiteralNode {
|
||||
frame.materialize(),
|
||||
parent,
|
||||
createListMembers(frame, parent.getLength()),
|
||||
parent.getLength() + keyNodes.length);
|
||||
// `[x] = y` overrides existing element and doesn't increase length
|
||||
parent.getLength());
|
||||
}
|
||||
|
||||
@Specialization
|
||||
|
||||
Reference in New Issue
Block a user