Open bvalyou opened 5 months ago
Thanks for the report. This is a hard problem; most other language plugins can't do this either. The only one I'm aware of that can do this is Kotlin.
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.
Thanks for a great minimal repro, though!
Relates to https://github.com/apple/pkl/issues/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