Open swift-ci opened 8 years ago
Personally, I'd prefer a syntax more like compiler diagnostics:
\(file):\(line): assertion failed: \(message)
I believe the current format comes from C:
Assertion failed: (0 && "hello!"), function main, file <stdin>, line 4.
although with a few slight differences.
So it's not clear that yours is "better".
Comment by Zhifu Ge (JIRA)
I don't have a preference over your format or that of C's.
What I meant by "not perfect" is:
1) the second colon is before rather than after the word "file"
2) there is not colon after the word "line", not consistent with other parts of the line.
Comment by Zhifu Ge (JIRA)
We don't need to change the format, just need to put colons in the right places.
Environment
Apple Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Standard Library | |Labels | Improvement | |Assignee | None | |Priority | Medium | md5: 9068f874a4c60373f6252c0cd61b70bbIssue Description:
When one calls
assert(booleanExpression, message)
and the booleanExpression is evaluated to be false, assertion will be failed and the output should be like this:
assertion failed: message file: path/to/file, line: lineNumber
but actually, the output is like this (notice the position and the missing of the colons):
assertion failed: message: file path/to/file, line lineNumber
For example:
let age = -2
assert(age >= 0), "A person's age cannot be less than zero.")
the output is:
assertion failed: A person's age cannot be less than zero.: file /var/folders/cj/3vtljk7s5pndy1wrwx88jpmc0000gn/T/lldb/938/repl79.swift, line 46
ideally, this above output should be formatted to:
assertion failed: A person's age cannot be less than zero. file: /var/folders/cj/3vtljk7s5pndy1wrwx88jpmc0000gn/T/lldb/938/repl79.swift, line: 46