Function types (#6891)

* Change Fn to fn for function types

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Support args and return types in function types

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Use fancy function types in the docs

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-05-13 14:59:23 +12:00
committed by GitHub
parent 47feae3bd9
commit 01c7b69f50
16 changed files with 209 additions and 47 deletions

View File

@ -4,7 +4,8 @@ description: Error from executing argument_error.kcl
---
KCL Semantic error
× semantic: f requires a value with type `Fn`, but found array (list)
× semantic: f requires a value with type `fn(any): any`, but found array
│ (list)
╭─[5:1]
4 │
5 │ map(f, f = [0, 1])
@ -14,7 +15,8 @@ KCL Semantic error
╰────
╰─▶ KCL Semantic error
× semantic: f requires a value with type `Fn`, but found array (list)
× semantic: f requires a value with type `fn(any): any`, but found
│ array (list)
╭─[5:12]
4 │
5 │ map(f, f = [0, 1])