Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10467] Argument type 'KeyPath<String, Int>' does not conform to expected type 'Any' #52867

Closed
stephencelis opened this issue Apr 12, 2019 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself key paths Feature: key paths (both native and Objective-C) type checker Area → compiler: Semantic analysis

Comments

@stephencelis
Copy link
Contributor

Previous ID SR-10467
Radar None
Original Reporter @stephencelis
Type Bug
Status Resolved
Resolution Done
Environment

Swift 5: including master / 0de62cb148ea4b2de5ff90bd93fc487cc4a59183

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, KeyPaths, TypeChecker
Assignee @stephencelis
Priority Medium

md5: 6b0b7068fd25aeff9a2895f24874a513

Issue Description:

The following code:

print(\String.count) 

Leads to:

error: argument type 'KeyPath<String, Int>' does not conform to expected type 'Any'

Attempting to cast:

print(\String.count as Any) // or print("\(\String.count)")

Leads to:

Fatal error: load from misaligned raw pointer

  • thread Redundant Load Elimination Patches #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

    frame #0: 0x00007fff6c5b3483 libswiftCore.dylib`function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift.fatalErrorMessage(: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 307

libswiftCore.dylib`function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift.fatalErrorMessage(: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never:

-> 0x7fff6c5b3483 <+307>: ud2

0x7fff6c5b3485 \<+309\>: movq   %r12, %rdi

0x7fff6c5b3488 \<+312\>: addq   $0x10, %rdi

0x7fff6c5b348c \<+316\>: cmpl   $0x80, %r14d
@belkadan
Copy link
Contributor

The latter problem is a known issue (SR-10117), but the former is suspicious. @xedin, @jckarter, have you seen this before?

@xedin
Copy link
Member

xedin commented Apr 12, 2019

Looks like this is at least not a regression because 4.2 has the same behavior, but I'm not really sure what is going on there. @jckarter do you mind taking a look?

@jckarter
Copy link
Member

Maybe the `KeyPath` constraint is being considered ambiguous because it's in `Any` context, and the code that tries to favor the most specific possible `KeyPath` type is failing?

@xedin
Copy link
Member

xedin commented Apr 25, 2019

I have fixed this via PR - #24234

@stephencelis Please use next available nightly master build to verify.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself key paths Feature: key paths (both native and Objective-C) type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

4 participants