mirror of
https://github.com/apple/pkl.git
synced 2026-05-28 01:29:15 +02:00
Eagerly check listing/mapping in iterables (#752)
There is currently a bug around resolving variables within the iterable of a for generator or spread syntax (https://github.com/apple/pkl/issues/741) Normally, mappings/listings are type-checked lazily. However, this results in the said bug getting widened, for any object members declared in the iterable. As a workaround for now, prevent the bug from being any worse by ensuring that these object members are eagerly typechecked.
This commit is contained in:
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
class Aviary {
|
||||
birds: Listing<Bird>
|
||||
}
|
||||
|
||||
class Bird {
|
||||
age: Int
|
||||
}
|
||||
|
||||
function Bird(_age: Int) = new Bird { age = _age }
|
||||
|
||||
res1 {
|
||||
for (i in IntSeq(1, 1)) {
|
||||
for (j in
|
||||
new Aviary {
|
||||
birds {
|
||||
Bird(i)
|
||||
}
|
||||
}.birds
|
||||
) {
|
||||
j
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res2 {
|
||||
for (i in IntSeq(1, 1)) {
|
||||
...new Aviary {
|
||||
birds {
|
||||
Bird(i)
|
||||
}
|
||||
}.birds
|
||||
}
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
res1 {
|
||||
new {
|
||||
age = 1
|
||||
}
|
||||
}
|
||||
res2 {
|
||||
new {
|
||||
age = 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user