You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-6913 Default arguments are not evaluated correctly in larger expression
Issue Description:
By creating struct to obtain source code context information, I expected that default parameter in my custom error initialiser will be execute in external context, like similar default parameters #file, #line, #function. But that didn't.
structSourceCodeContext{letfile:Stringletline:Intletfunction:Stringinit(_ file:String= #file, _ line:Int= #line, _ function:String= #function){self.file = file
self.line = line
self.function = function
}}structSomeError:Error{letcontext:SourceCodeContextinit(_ context:SourceCodeContext=SourceCodeContext()){self.context = context
}}leterror=SomeError()
error.context.line /// expected 25, but has initializer line value - 21
error.context.function /// `init` value
Environment: Xcode 10.1 (10B61)
The text was updated successfully, but these errors were encountered:
I think this is correct behavior; otherwise you wouldn't be able to find where the SourceCodeContext initializer was called. But it might be worth bringing up on the forums.
Additional Detail from JIRA
md5: 9783f89900de35561fa484416cd4b302
duplicates:
Issue Description:
By creating struct to obtain source code context information, I expected that default parameter in my custom error initialiser will be execute in external context, like similar default parameters #file, #line, #function. But that didn't.
Environment: Xcode 10.1 (10B61)
The text was updated successfully, but these errors were encountered: