() is refused as a type the compiler can’t tell (NK1245), not as a method the type lacks (NK1171)Open and answer this issue on GitHub.
ready · opened 2026-11-19 · updated 2026-11-19 · 0 comments
Found while drafting “The lock tests of std move into Nikaia programs” (#2189). No item of it waits for this: its programs use set(…; after:) under catch, as Part I 7.1 asks, and never call a method on the result. A reader who expects set to hand back a Result (and calls .is_ok() on it) meets this message instead of one that says what is wrong.
Binary: target/release/nikaia (nikaia 0.1.0, built 2026-11-18 06:16 from develop), run in a scratch directory outside the checkout with nikaia run FILE.
fn main() throws {
let n: SharedMut[Vec[i64]] = SharedMut([0])
let r = n.set([1]; after: [0])
println(f"{r.is_ok()}")
}
error[NK1245]: The compiler can't tell what type `r.is_ok()` is.
--> isok.nika:4:5
|
4 | println(f"{r.is_ok()}")
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= note: What is not known is not checked, so a type nothing can tell is refused rather than left to the language below.
= help: Write the type down where the value is made, such as `let x: T = …`, or pass it to a parameter that declares one.
1 type error
Exit 1. The compiler does know the type of r: set hands back nothing, so r is (). The help asks for a type annotation, which cannot help.
The same NK1245, with nothing of the lock in it:
let r = n.set([1]) (a plain set): NK1245 on r.is_ok().fn noop() { let _x = 1 }, then let r = noop() and r.is_ok(): NK1245.let t = (1, 2), then t.is_ok(): NK1245 on t.is_ok().The same call on other types gives the right refusal:
let r: i64 = 3, then r.is_ok(): error[NK1210]: \i64` has no method called `is_ok`.`struct P { x: i64 }, then p.is_ok(): error[NK1171]: \P` has no method called `is_ok`.`No open issue names it (searched the titles for NK1245 with tuple and with method).
docs/specification/30-nikaia-tooling.md: NK1171 is a member nothing writes down; NK1245 is an expression whose type the compiler cannot tell (C.4). The type of r and of t is known, so the refusal is NK1171.error[NK1171]: \()` has no method called `is_ok`. and error[NK1171]: `(i64, i64)` has no method called `is_ok`., each with the note a_member_is_refused` gives a type with no members.catch; there is no Result to ask. A note that says so where the type is () and the method is is_ok / is_err is welcome but not required.Suspected, from reading the code; item 1 checks it with a probe.
check_core_call_on in crates/nikaia-std/src/compiler/check_core_call_on.nika ends a call it does not know with state.a_member_nothing_writes_down(world, type_name, entry, true, span) (around line 412).type_name comes from check_core_call_on_type_name (line 125), which names a Ty::Named, a Seq and a slice, and gives "" for anything else, a Ty::Tuple among them (() is Ty::Tuple([])).a_member_nothing_writes_down in crates/nikaia-std/src/compiler/check_members.nika (line 148) returns at once when the head is not declared (if !declared { return }); "" is never declared. Nothing is refused, the call’s type stays Ty::Unknown, and the later C.4 check refuses it as NK1245.nikaia run scripts/where.nika -- check_core_call_on_type_name and a probe that prints the head a_member_nothing_writes_down receives for t.is_ok() (expected ""). A cause shown false is answered wrong I7: ... in the report.() that no std entry and no trait provides as NK1171, naming the type as Ty::shown() writes it. The tuple methods std does describe (if any; item 1 lists them) stay accepted. Test: tests/compiler/tests/a_method_on_a_tuple_or_nothing_is_refused_as_missing.nika with its .stderr: is_ok on the result of set(…; after:), on the result of a function without a result, and on (1, 2); each gives NK1171, none NK1245.check_core_call_on that take type_name (nothing_says_what_a_parameter_can_do, no_number_has_this_method, a_list_collected) and the path and field checks in check_members.nika (t.name on a tuple, ().x): each that ends in NK1245 for a known type is fixed alike, with its case in the test of item 2. Name each one checked in the report.() or (i64, i64), exit 1, and no NK1245.int_m still gives NK1210 and struct_m still NK1171.Fixes #N (#N being this issue’s number); the others say Part of #N.Found: line for each defect met on the way.crates/nikaia-std/src/compiler/check_core_call_on.nika and check_members.nika; their lowered .rs is output.tests/compiler/tests/ (the program and its .stderr).r: let r = n.get() with r.is_ok() on a SharedMut[i64] gives NK1210 for i64, so the type flows; only the tuple head is lost.