/* A sized literal of a QUALIFIED named slice type: `lib.Nat{:3}`. Named slice types are allowed and can be sized with the `T{:n}` form. When T is qualified, the qualifier is part of the type expression the literal lowers to; the text rewriter used to start at the type name and emitted `lib.__slicealloc(Nat, 3)`, which is undefined in the importing package. */ package main import "tests/regressions/should_compile/named_slice_sized_literal/lib" func main() { // Termination: a batch program must still be stoppable, so the entry // handles the channel the runtime closes on SIGINT/SIGTERM. select { case <-shutdown: return default: } var n lib.Nat = lib.Nat{:3} n[0] = 1 n[1] = 2 n[2] = 3 if lib.Sum(n) != 6 || len(n) != 3 || cap(n) != 3 { panic("lib.Nat{:3} did not size a named slice") } var local lib.Nat = lib.Nat{:2:4} local[1] = 5 if len(local) != 2 || cap(local) != 4 || local[1] != 5 { panic("lib.Nat{:2:4} did not size a named slice") } println("named slice sized literal ok") }