Skip to content

bug: disallow wildcard type ? in named return value positions #1557

@SchoolyB

Description

@SchoolyB

Description

Named return values with wildcard types (-> (first ?, count int)) create an unresolvable conflict. The function body cannot declare a variable with type ? since wildcards are only valid in function signatures, so the named return can never be satisfied.

Repro

do first_and_len(arr [?]) -> (first ?, count int) {
    mut first = arr[0]
    mut count int = len(arr)
    return first, count
}

Expected: Rejected with a clear error — wildcard type ? cannot be used in named return positions.

Actual: Compiles past the parser but fails with E4001 (undefined variable).

Fix

Reject ? in named return positions at typecheck time with E3081. The valid alternative is an unnamed return: -> (?, int).

Update STANDARD.md sections 7.3.4 and 7.9 to document this restriction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtypecheckerRelated to type checking and validation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions