Vec[i64](), is refused or fails in rustcOpen and answer this issue on GitHub.
ready · opened 2026-11-21 · updated 2026-11-21 · 1 comment
Found while deciding “A grammar arm cannot make an empty map of the field’s own type T” (#2626), for the TOML reader (#2602). Area: checker, lowering.
ADR-306 D12 writes let mut row = Vec[i64]() as an ordinary line; it does not compile.
target/fast/nikaia run gN.nika)fn main() {
let mut row = Vec[i64]()
row.push(1)
println(f"{row.len()}")
}
→ error[NK1117]: i64 isn't declared anywhere. at Vec[i64](): the generic is read as an index expression.
use std::collections
fn main() {
let mut m = collections::HashMap[String, i64]()
m.insert("a", 1)
println(f"{m.len()}")
}
→ the same NK1117 for i64. With [String, String] it is error[NK1245]: The compiler can't tell what type collections::HashMap is.
fn main() throws {
let mut v = Vec[String]()
v.push("a")
println(f"{v.len()}")
}
→ accepted by the checker, then error[NK1343]: Internal compiler error. (rustc: the trait bound fn() -> List<_> {List::<_>::new}: Get<_>` is not satisfied`): lowered as an index into the constructor function.
Each probe prints 1. A type with its generics written, followed by (), is a call of that type’s constructor, as ADR-306 D12 uses it.
Type[Args](...) (also module::Type[Args](...)) as a constructor call with explicit generics when Type names a type, not an index of a value.Type::<Args>::new() (the Rust the constructor lowers to).tests/compiler/tests/constructor_explicit_generics.nika: the three probes in one main, with .stdout 1 three times.That test passes under --both-settings, and the ADR-306 D12 example compiles.
Note from the supervisor: the fix for “Vec[String]() reaches rustc as an index into the constructor: internal error NK1343” (#2635, commit a92cf3bcc, local, goes out with the safety driver’s next push) refuses Type[Args]() with NK1245 and a help line pointing to let x: Vec[String] = Vec(). That ends the internal error; it does not decide this issue. ADR-grammar-typed-read-v1 D14 rejects explicit generics only as the answer to #2626, not in general. Whoever builds this issue turns that refusal into the accepted call and rewrites tests/compiler/tests/a_constructor_with_generics_is_refused_not_lowered.stderr accordingly (a change of decision, not a loosened output).
Generated by Claude Code