Originally created by @bioball on GitHub (Sep 6, 2024).
This snippet this evaluates to result = true:
hidden myFunc = (it: String) -> it
result = myFunc is (Int) -> String
It's not possible to typecheck a function type (beyond simply Function). A better behavior here is probably to just throw an error, because it's impossible to know if above expression should be true or false.
However, we should be able to type cast functions. This snippet does not throw, but should:
hidden myFunc = (it) -> it
hidden fooFunc: (String) -> String = myFunc
result = (fooFunc as (String) -> String).apply(1)
I'd expect an error like:
–– Pkl Error ––
Expected value of type String, but got type Int.
Value: 1
1 | result = (fooFunc as (String) -> String).apply(1)
^^^^^^
Originally created by @bioball on GitHub (Sep 6, 2024).
This snippet this evaluates to `result = true`:
```pkl
hidden myFunc = (it: String) -> it
result = myFunc is (Int) -> String
```
It's not possible to typecheck a function type (beyond simply `Function`). A better behavior here is probably to just throw an error, because it's impossible to know if above expression should be true or false.
However, we should be able to type cast functions. This snippet does not throw, but should:
```pkl
hidden myFunc = (it) -> it
hidden fooFunc: (String) -> String = myFunc
result = (fooFunc as (String) -> String).apply(1)
```
I'd expect an error like:
```
–– Pkl Error ––
Expected value of type String, but got type Int.
Value: 1
1 | result = (fooFunc as (String) -> String).apply(1)
^^^^^^
```
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 @bioball on GitHub (Sep 6, 2024).
This snippet this evaluates to
result = true:It's not possible to typecheck a function type (beyond simply
Function). A better behavior here is probably to just throw an error, because it's impossible to know if above expression should be true or false.However, we should be able to type cast functions. This snippet does not throw, but should:
I'd expect an error like: