Home / Docs / Diagnostics
U2021: A function with edit or take parameters used as a value
Release v0.4.0
Function types have no conventions, so a function with an edit or take parameter cannot be used as a value: naming it anywhere but in the callee position of a call is U2021 (spec/17 §3 rule 7). Call it directly, or wrap the call in a function or lambda without conventions.
The repair at a glance
src/demo.una
module demo
- pub drain(take items: List[Int]) -> Int = items.len
+ pub size(items: List[Int]) -> Int = items.len
- pub sizes(groups: List[List[Int]]) -> List[Int] = groups.map(each: drain)
+ pub sizes(groups: List[List[Int]]) -> List[Int] = groups.map(each: size)Failing example
una.toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.2"src/demo.una
module demo
pub drain(take items: List[Int]) -> Int = items.len
pub sizes(groups: List[List[Int]]) -> List[Int] = groups.map(each: drain)Fixed example
una.toml
[package]
name = "demo"
version = "0.1.0"
edition = "0.2"src/demo.una
module demo
pub size(items: List[Int]) -> Int = items.len
pub sizes(groups: List[List[Int]]) -> List[Int] = groups.map(each: size)