Skip to content

[SR-4246] Generic Parameter is Missing in Vague Error Message #46829

@palimondo

Description

@palimondo
mannequin
Previous ID SR-4246
Radar None
Original Reporter @palimondo
Type Bug

Attachment: Download

Environment

Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee None
Priority Medium

md5: 1bda1dd32a2bee653ddb7117169bec0e

Issue Description:

Following code:

public struct ComposedSequence<Element, State> {
    var _state: State
    var _next: (inout State) -> Element?
}

func composePrefix<BaseIterator : IteratorProtocol>(_ prefix: Int, _ iterator: BaseIterator) -> ComposedSequence<BaseIterator.Element, (count: Int, iterator: BaseIterator)> {

    func _prefix(state: inout (count: Int, iterator: BaseIterator)) -> BaseIterator.Element? {
        return nil
    }
    
    // The first member in tuple is deliberatly of wrong type (String instead of Int) to force error
    return ComposedSequence(_state: ("prefix", iterator), _next: _prefix)
}

produces following compiler error (scroll right for the interesting part):

GenericParameterMissingInVagueErrorMessage.swift:13:66: error: cannot convert value of type '(inout (count: Int, iterator: BaseIterator)) -> BaseIterator.Element?' to expected argument type '(inout (String, _)) -> _?'
        return ComposedSequence(_state: ("prefix", iterator), _next: _prefix)
                                                                     ^~~~~~~

Notice how the generic parameter BaseIterator is missing from the reported expected type:
(inout (String, _)) -> _?

That type should be (inout (String, BaseIterator)) -> BaseIterator.Element?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationgenericsFeature: generic declarations and typestuplesFeature: tuplestype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions