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-9230] Crash with protocol-typed argument for @dynamicCallable method #51718
Comments
Ah darn, thanks for finding the bug! Somehow I never thought to test default arguments when implementing EDIT: The problem occurs even when default arguments (for both methods) are removed. So the problem seems unrelated to default arguments. |
Interesting, removing the protocol // This doesn't crash.
@dynamicCallable
struct Struct {
func dynamicallyCall(withArguments args: [Struct] = []) {}
func dynamicallyCall(withKeywordArguments args: DictionaryLiteral<String, Struct> = [:]) -> Struct {
return Struct()
}
}
func crasher() {
let a = Struct()
a(a(a, key: a))
} |
Incidentally, I lean towards the opinion that default arguments on This is just the natural behavior: @dynamicCallable
struct Callable {
func dynamicallyCall(withArguments: [Int]) {}
}
let c = Callable()
c() // This always sugars to `dynamicallyCall(withArguments: [])`.
// Never sugars to `dynamicallyCall()` (using default arguments). We could change |
The "tuple_expr element type mismatch" error happens during AST verification. I dumped the AST of the code with the direct call (i.e. $ swiftc -dump-ast dc.swift
... // whole bunch of stuff
(erasure_expr implicit type='Proto' location=dc.swift:29:92 range=[dc.swift:29:92 - line:29:92]
(normal_conformance type=Struct protocol=Proto)
(declref_expr type='Struct' location=dc.swift:29:92 range=[dc.swift:29:92 - line:29:92] decl=dc.(file).crasher().a@dc.swift:25:7 function_ref=unapplied))) In CSApply.cpp, perhaps generating |
Comment by Parker Schuh (JIRA) This has been fixed in the tensorflow branch. |
Additional Detail from JIRA
md5: 8ae887542ad4bffb4db2001ae7cd1475
Issue Description:
I get this error:
For this code:
The text was updated successfully, but these errors were encountered: