You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Subtype checks do not register within a compound conditional if the object being type checked is dereferenced from another variable.
How to reproduce
It's actually pretty interesting - I've spent the last 20 minutes trying to find a minimal reproducible example and after talking through it for a few minutes, I found it.
This does not reproduce it:
import "@k8s/K8sResource.pkl"
import "@k8s/api/core/v1/ConfigMap.pkl"
function testCompoundCondition(resource: K8sResource) = resource is ConfigMap
&& resource.metadata.name == "foo" // metadata autocompletes
This does:
import "@k8s/K8sResource.pkl"
import "@k8s/api/core/v1/ConfigMap.pkl"
class ThingWithK8sResource {
resource: K8sResource
}
function testCompoundCondition(thing: ThingWithK8sResource) = thing.resource is ConfigMap
&& thing.resource.metadata.name == "foo" // Unresolved reference: metadata
More details
When amending a Listing<K8sResource> to update a named ConfigMap, this member predicate line is not recognizing that we already know the K8sResource is of subtype ConfigMap, which has a metadata attribute:
[[this is ConfigMap && metadata.name == environment.resourceName("app-env")]] {
On the subsequent line the amend body properly identifies the data attribute as belonging to the ConfigMap, but it's not resolved within the predicate itself.
Versions
Pkl 0.25.2
Pkl IntelliJ 0.26.0
The text was updated successfully, but these errors were encountered:
bioball
changed the title
Compound conditionals sometimes don't register prior type checks
Cannot flow-type through qualified access
Apr 9, 2024
I know that Hack struggled with this too, at least, after any method was called on the outer object. In their case, it's duet mutability. Since Pkl is immutable, this should (famous last words) be generally decidable.
Relates to apple/pkl#402
Summary
Subtype checks do not register within a compound conditional if the object being type checked is dereferenced from another variable.
How to reproduce
It's actually pretty interesting - I've spent the last 20 minutes trying to find a minimal reproducible example and after talking through it for a few minutes, I found it.
This does not reproduce it:
This does:
More details
When amending a
Listing<K8sResource>
to update a namedConfigMap
, this member predicate line is not recognizing that we already know theK8sResource
is of subtypeConfigMap
, which has ametadata
attribute:On the subsequent line the amend body properly identifies the
data
attribute as belonging to theConfigMap
, but it's not resolved within the predicate itself.Versions
Pkl 0.25.2
Pkl IntelliJ 0.26.0
The text was updated successfully, but these errors were encountered: