mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
is operator does not take current scope into account
#213
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sin-ack on GitHub (Oct 8, 2024).
Reproducer:
Error message:
This is contradictory with
List.filterIsInstancewhich can take an arbitrary class at evaluation time (from what I can understand).@bioball commented on GitHub (Oct 8, 2024):
isaccepts a type, rather than an expression, and types and values exist in different namespaces.This is intentional, and changing this would be a breaking change for how
isworks. It's akin toisin Kotlin, Swift, etc.@sin-ack commented on GitHub (Oct 11, 2024):
Sorry for not getting back on this. I disagree with the decision but respect it. Is there a way to achieve what I want to do in Pkl, then, without resorting to tons of separate
foo is Classchecks?@bioball commented on GitHub (Oct 11, 2024):
You can compare the class values directly, e.g.
@sin-ack commented on GitHub (Oct 11, 2024):
That works, thanks for the solution.
@odenix commented on GitHub (Oct 13, 2024):
@bioball How about adding method
Class.isInstance(value)tobase.Class?@bioball commented on GitHub (Oct 13, 2024):
I'm open to it! Feel free to submit a PR for it. Maybe
hasInstanceis a better name.