V2003 not_callable
The callee of a call expression is not a function: a value of another type is followed by (…).
An error from the type phase. sakura explain V2003 prints this explanation offline.
The callee of a call expression is not a function: a value of another type is followed by
(…). Check that the name refers to the function you meant (a local can shadow it), or remove
the call.
Wrong:
let x = 1
x(2)Fixed:
let x = fn(n: Int) { n + 1 }
x(2)Wrong program
compiler/tests/ui/V2003_not_callable.sakura, which the compiler's ui suite runs through sakura check:
fn call() -> Int {
let x = 1
x(2)
}sakura check --json reports this record (pretty-printed; $DIR is the fixture's directory):
{
"schema_version": "1.0",
"kind": "diagnostic",
"id": "d:ac6f003eea3f17d8",
"code": "V2003",
"severity": "error",
"phase": "type",
"message": "`Int` is not a function, so it cannot be called",
"snapshot": "sha256:$SNAPSHOT",
"symbol_id": "main::V2003_not_callable::call",
"spans": [
{
"uri": "file://$DIR/V2003_not_callable.sakura",
"content_hash": "sha256:3fa13dd548ca2d0ccd72eaaa3fba486cdf2d3296071bc7d16c036474f7c6c401",
"start_byte": 67,
"end_byte": 71,
"role": "primary"
}
],
"related_ids": [],
"expected": null,
"actual": null,
"obligation": null,
"counterexample": null,
"explanation_uri": "sakura://explain/V2003",
"fixes": []
}Fixed program
compiler/tests/ui/V2003_not_callable.fixed.sakura, which sakura check accepts with no diagnostics:
fn call() -> Int {
let x = fn(n: Int) { n + 1 }
x(2)
}