Skip to content

Missing compiler warning #70630

Closed as not planned
Closed as not planned
@bastie

Description

@bastie

typo - see error description 2 days later 🥺

Description

In result of overload functions / methods with same name but more parameters and these parameters get default values (line 23) the "simple" function (line 20) appears uncallable.

Bildschirmfoto 2023-12-26 um 16 45 33

Reproduction

//
//  main.swift
//  MissingInitInfo
//
//  Created by Sebastian Ritter on 26.12.23.
//

import Foundation

// ✅ expected error
//let _ = Printable ()

// 🆘 name is not set, but called is init with param *as name* and ignoring init without second parameter
let _ = Printable (from: "Sebastian")

// ✅ expected result
let _ = Printable (from: "Sebastian", as: "Mr. Ritter")

public class Printable {
  public init (form sender : String) { // 🆘 uncallable (?) init method but no compiler message
    print ("Hello from \(sender)!")
  }
  public init (from sender : String, as name : String = "Bastie") {
    print ("Hello from \(name)?")
  }
}

Expected behavior

Compiler warning at line 20 as uncallable method / function

Environment

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerThe Swift compiler itselfdefault argumentsFeature: default arguments for value parametersmissing warningBug: Missing warningnot a bugResolution → not a bug: Reported as a bug but turned out to be expected behavior or programmer erroroverload resolutionArea → compiler → type checker: Overload resolution (ranking)swift 5.9type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions