Skip to content

D126/D127 (§4.3c, §3.1): a slice demand does not type a literal or a constant in argument position — sum([1, 2, 3]) and first(NAMES) are "wrong argument type" #2944

Closed

Description

@ehartford

Conformance audit 2026-11-02. Spec v7.32 (D126, D127; README changelog says "the implementation is NON-COMPLIANT until it catches up") — §4.3c: "A slice demand supplies the element type to a literal in argument position and views it; it demands no collection." §3.1: a view of a constant is a view of an immutable static.

Installed compiler (main 038c50c):

fn sum(xs: &[i32]) -> i32:
    var t = 0
    for x in xs: t = t + x
    t
print(sum([1, 2, 3]))
error: wrong argument type in call to 'sum'
const NAMES = ["a", "b"]
fn first(xs: &[str]) -> str: xs[0]
print(first(NAMES))
error: wrong argument type in call to 'first'

(The by-use form let ys = [4, 5]; total(ys) with total(xs: List[i32]) passes, so D93 is in; the slice demand is what is missing.) Done when both compile and run, with behavior fixtures.

Activity

  1. added
    bug
    spec-gap
    on Nov 2, 2026
  2. added a commit that references this issue on Nov 2, 2026
  3. ehartford commented on Nov 2, 2026

    @ehartford
    ContributorAuthor

    Closed by #2992: the example was wrong, not the compiler (#2987's rule). &[i32] is a reference to a slice (&[]i32); the slice is []i32, and with it sum([1, 2, 3]), sum(ys) and first(NAMES) compile and run. The argument-mismatch diagnostic now says so when a parameter is &[]T.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugspec-gap

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions