As far as I understand, this should fail because isDistinctBy wouldn't be unique for each element.
Using next example I managed to get error:
class ListingClass {
inner: Listing<Int16>(isDistinctBy((d) -> "not unique"))
}
temp2 = new ListingClass {
inner = new Listing {
1 2 3 4
}
}
output {
renderer = new YamlRenderer {}
}
which gave following output
Type constraint `isDistinctBy((d) -> "not unique")` violated.
...
I think examples are very similar and both should fail, but latter adds more complexity that I'd like to avoid. Am I doing something completely wrong or this is expected? If any of those are the case, let me know and I will close the issue.
Originally created by @miroslav-filipovic on GitHub (Feb 28, 2024).
I tried following example using 0.25.2 and 0.26.0, but both versions passed with no error.
```
typealias ListingAlias = Listing<Int16>(isDistinctBy((d) -> "not unique"))
temp1 = new ListingAlias {
1 2 3 4
}
output {
renderer = new YamlRenderer {}
}
```
As far as I understand, this should fail because `isDistinctBy` wouldn't be unique for each element.
Using next example I managed to get error:
```
class ListingClass {
inner: Listing<Int16>(isDistinctBy((d) -> "not unique"))
}
temp2 = new ListingClass {
inner = new Listing {
1 2 3 4
}
}
output {
renderer = new YamlRenderer {}
}
```
which gave following output
```
Type constraint `isDistinctBy((d) -> "not unique")` violated.
...
```
I think examples are very similar and both should fail, but latter adds more complexity that I'd like to avoid. Am I doing something completely wrong or this is expected? If any of those are the case, let me know and I will close the issue.
Right now, Pkl doesn't execute type checks when you do new Listing<Type>, or new Mapping<Type, Type>. This is a known bug.
To get these type checks to execute, you need to assign the type to your property.
For example:
temp1: ListingAlias = new { 1; 2; 3; 4 }
@bioball commented on GitHub (Feb 28, 2024):
Right now, Pkl doesn't execute type checks when you do `new Listing<Type>`, or `new Mapping<Type, Type>`. This is a known bug.
To get these type checks to execute, you need to assign the type to your property.
For example:
```
temp1: ListingAlias = new { 1; 2; 3; 4 }
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @miroslav-filipovic on GitHub (Feb 28, 2024).
I tried following example using 0.25.2 and 0.26.0, but both versions passed with no error.
As far as I understand, this should fail because
isDistinctBywouldn't be unique for each element.Using next example I managed to get error:
which gave following output
I think examples are very similar and both should fail, but latter adds more complexity that I'd like to avoid. Am I doing something completely wrong or this is expected? If any of those are the case, let me know and I will close the issue.
@bioball commented on GitHub (Feb 28, 2024):
Right now, Pkl doesn't execute type checks when you do
new Listing<Type>, ornew Mapping<Type, Type>. This is a known bug.To get these type checks to execute, you need to assign the type to your property.
For example:
@miroslav-filipovic commented on GitHub (Feb 28, 2024):
Nice, thanks!