Skip to content

[SR-12689] Undiagnosed argument mismatch involving pointer types #55133

@LucianoPAlmeida

Description

@LucianoPAlmeida
Previous ID SR-12689
Radar rdar://problem/62481592
Original Reporter @LucianoPAlmeida
Type Bug
Status Closed
Resolution Done
Environment

GitHub master, 013387e

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

md5: 7f41b7e664097a5b9aac7ea8e9ef1c6e

Issue Description:

That's from this forum discussion https://forums.swift.org/t/error-type-of-expression-is-ambiguous-without-more-context/35816
I just minimize the sample code to reproduce it

func a(_ u: UnsafeBufferPointer<UInt16>) {}

let array : [UInt16] = [1, 2]

array.withUnsafeBufferPointer {
  a(UnsafeRawPointer($0).bindMemory(to: UInt16.self, capacity: 1)) // type of expression is ambiguous without more context

// Also

UnsafeRawPointer($0) as UnsafePointer<UInt16> // type of expression is ambiguous without more context
}

Simple examples to reproduce

func foo(_ u: Int) -> String { "" }
func foo(_ u: String) -> Double { 0 }

func bar(_ u: Int) {}

bar(foo(1 as Double))  // type of expression is ambiguous without more context

foo(1 as Double) as Int  // type of expression is ambiguous without more context

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 Implementationtype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions