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
md5: b802d9f73456058327d450079e18b6e4
Issue Description:
For my hypothetical MyArray implementation, in normal functions I can write
MyArray
function get(index: Int, file: StaticString = #file, line: UInt = #line) -> Value { if !checkIndex(index) { fatalError("index \(index) out of bound", file: file, line: line) } ... }
and I'll be able to create good error messages for the user.
In subscripts however, default arguments are disallowed so
subscript(index: Int) -> Value { if !checkIndex(index) { fatalError("index \(index) out of bound") } .... }
will always show its literal line and file rather than the callers.
The text was updated successfully, but these errors were encountered:
That should look like this:
struct A { subscript(a: Int, file: String = #file) -> Int { print(file) return a } } print(A()[1])
but we don't allow default arguments in subscripts at the moment (because it's unclear how they would work with inout subscripts).
Sorry, something went wrong.
@belkadan, sorry, could you expand on the inout subscripts? I don't know what they are 🙂
#23734
Comment by Joseph Twomey (JIRA)
@swift-ci create
slavapestov
No branches or pull requests
weissi commentedOct 11, 2017
Additional Detail from JIRA
md5: b802d9f73456058327d450079e18b6e4
Issue Description:
For my hypothetical
MyArray
implementation, in normal functions I can writeand I'll be able to create good error messages for the user.
In subscripts however, default arguments are disallowed so
will always show its literal line and file rather than the callers.
The text was updated successfully, but these errors were encountered: