mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
For class properties with type constraints, instances that violate those constraints should be included in the error report #82
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 @Senjai on GitHub (Feb 19, 2024).
Playground: https://pkl-playground.vercel.app/?share=strike-what-planet
(Please let me know if this stuff should be a discussion instead)
When instantiating a class e.g.
thing = new Thing {}, if at the time of evaluation a type constraint is violated, the line where the instantiation occured should be included in the error output.The following:
Yields
The error here correctly identifies which type constraint is violated, but not where that type constraint was violated. The value hint may be helpful, but at the top, there should probably be a file reference to the line
invalidExample = new TypeConstrained {}For this example specifically, I am not aware of a better way to ensure a Listing is actually defined for this key rather than just defaulting
@bioball commented on GitHub (Feb 23, 2024):
This is definitely something that needs to be improved. Right now, we don't preserve enough information in runtime object to present errors like this, and we'd need to balance this with performance concerns when considering this feature.