func ok() {
let s = "see"; "Why are there exactly "
0 == 0 * 42
"warnings and errors in this code"
let t = s + "?"
print(t)
}
ok() // see?
Because currently only unused variable/constant declarations have
warnings/fix-its attached to them.
There have been some discussion on making non-void functions warn of unused
results
<https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001580.html>
and it’s possible that this would be in style with that.
Perhaps (basically) empty statements should also give a warning?
—Johan
···
On Mon, Dec 14, 2015 at 7:08 PM, Jens Persson via swift-dev < swift-dev@swift.org> wrote:
func ok() {
let s = "see"; "Why are there exactly "
0 == 0 * 42
"warnings and errors in this code"
let t = s + "?"
print(t)
}
ok() // see?_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev
Yes, and I don't know if there is any particular reason why the == operator
for Int doesn't have @warn_unused_result while the one for Doubles has:
func f() { 1 == 2 } // OK
func g() { 1.0 == 2.0 } // Warning: Result of call '==' is unused
···
On Mon, Dec 14, 2015 at 7:40 PM, Johan Jensen <jj@johanjensen.dk> wrote:
Because currently only unused variable/constant declarations have
warnings/fix-its attached to them.
There have been some discussion on making non-void functions warn of
unused results
<https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001580.html>
and it’s possible that this would be in style with that.
Perhaps (basically) empty statements should also give a warning?—Johan
On Mon, Dec 14, 2015 at 7:08 PM, Jens Persson via swift-dev < > swift-dev@swift.org> wrote:
func ok() {
let s = "see"; "Why are there exactly "
0 == 0 * 42
"warnings and errors in this code"
let t = s + "?"
print(t)
}
ok() // see?_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev
--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com
Yes, and I don't know if there is any particular reason why the == operator for Int doesn't have @warn_unused_result while the one for Doubles has:
func f() { 1 == 2 } // OK
func g() { 1.0 == 2.0 } // Warning: Result of call '==' is unused
That’s an oversight; please file a radar!
Because currently only unused variable/constant declarations have warnings/fix-its attached to them.
There have been some discussion on making non-void functions warn of unused results <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001580.html> and it’s possible that this would be in style with that.
Perhaps (basically) empty statements should also give a warning?—Johan
func ok() {
let s = "see"; "Why are there exactly "
0 == 0 * 42
"warnings and errors in this code"
let t = s + "?"
print(t)
}
ok() // see?_______________________________________________
swift-dev mailing list
swift-dev@swift.org <mailto:swift-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-dev--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
http://www.bitcycle.com/
Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com <mailto:jens@bitcycle.com>_______________________________________________
swift-dev mailing list
swift-dev@swift.org <mailto:swift-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-dev
-Dave
···
On Dec 14, 2015, at 11:04 AM, Jens Persson via swift-dev <swift-dev@swift.org> wrote:
On Mon, Dec 14, 2015 at 7:40 PM, Johan Jensen <jj@johanjensen.dk <mailto:jj@johanjensen.dk>> wrote:
On Mon, Dec 14, 2015 at 7:08 PM, Jens Persson via swift-dev <swift-dev@swift.org <mailto:swift-dev@swift.org>> wrote:
Ok thanks, and what about the initial topic of this thread, ie stuff like
this:
func f() {
1; "two"; 3.0
[4, 5]; 6 * 7
print("No warnings or errors!")
}
f() // No warnings or errors!
Should I file a bug for that too or is this by design / has this been
discussed somewhere already?
···
On Tue, Dec 15, 2015 at 11:54 PM, Dave Abrahams <dabrahams@apple.com> wrote:
On Dec 14, 2015, at 11:04 AM, Jens Persson via swift-dev < > swift-dev@swift.org> wrote:
Yes, and I don't know if there is any particular reason why the ==
operator for Int doesn't have @warn_unused_result while the one for Doubles
has:func f() { 1 == 2 } // OK
func g() { 1.0 == 2.0 } // Warning: Result of call '==' is unusedThat’s an oversight; please file a radar!
On Mon, Dec 14, 2015 at 7:40 PM, Johan Jensen <jj@johanjensen.dk> wrote:
Because currently only unused variable/constant declarations have
warnings/fix-its attached to them.
There have been some discussion on making non-void functions warn of
unused results
<https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001580.html>
and it’s possible that this would be in style with that.
Perhaps (basically) empty statements should also give a warning?—Johan
On Mon, Dec 14, 2015 at 7:08 PM, Jens Persson via swift-dev < >> swift-dev@swift.org> wrote:
func ok() {
let s = "see"; "Why are there exactly "
0 == 0 * 42
"warnings and errors in this code"
let t = s + "?"
print(t)
}
ok() // see?_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
http://www.bitcycle.com/
Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev-Dave
--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com
Filed:
···
On Tue, Dec 15, 2015 at 11:54 PM, Dave Abrahams <dabrahams@apple.com> wrote:
On Dec 14, 2015, at 11:04 AM, Jens Persson via swift-dev < > swift-dev@swift.org> wrote:
Yes, and I don't know if there is any particular reason why the ==
operator for Int doesn't have @warn_unused_result while the one for Doubles
has:func f() { 1 == 2 } // OK
func g() { 1.0 == 2.0 } // Warning: Result of call '==' is unusedThat’s an oversight; please file a radar!
On Mon, Dec 14, 2015 at 7:40 PM, Johan Jensen <jj@johanjensen.dk> wrote:
Because currently only unused variable/constant declarations have
warnings/fix-its attached to them.
There have been some discussion on making non-void functions warn of
unused results
<https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001580.html>
and it’s possible that this would be in style with that.
Perhaps (basically) empty statements should also give a warning?—Johan
On Mon, Dec 14, 2015 at 7:08 PM, Jens Persson via swift-dev < >> swift-dev@swift.org> wrote:
func ok() {
let s = "see"; "Why are there exactly "
0 == 0 * 42
"warnings and errors in this code"
let t = s + "?"
print(t)
}
ok() // see?_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
http://www.bitcycle.com/
Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev-Dave
--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com
Ok thanks, and what about the initial topic of this thread, ie stuff like this:
func f() {
1; "two"; 3.0
[4, 5]; 6 * 7
print("No warnings or errors!")
}
f() // No warnings or errors!Should I file a bug for that too or is this by design / has this been discussed somewhere already?
There is a discussion on the swift-evolution mailing list about making “@warn_unused_results” semantics the default for all non-void functions. To me, that seems like the cleanest path to address these issues.
-Chris
···
On Dec 15, 2015, at 3:42 PM, Jens Persson via swift-dev <swift-dev@swift.org> wrote:
On Tue, Dec 15, 2015 at 11:54 PM, Dave Abrahams <dabrahams@apple.com <mailto:dabrahams@apple.com>> wrote:
On Dec 14, 2015, at 11:04 AM, Jens Persson via swift-dev <swift-dev@swift.org <mailto:swift-dev@swift.org>> wrote:
Yes, and I don't know if there is any particular reason why the == operator for Int doesn't have @warn_unused_result while the one for Doubles has:
func f() { 1 == 2 } // OK
func g() { 1.0 == 2.0 } // Warning: Result of call '==' is unusedThat’s an oversight; please file a radar!
On Mon, Dec 14, 2015 at 7:40 PM, Johan Jensen <jj@johanjensen.dk <mailto:jj@johanjensen.dk>> wrote:
Because currently only unused variable/constant declarations have warnings/fix-its attached to them.
There have been some discussion on making non-void functions warn of unused results <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001580.html> and it’s possible that this would be in style with that.
Perhaps (basically) empty statements should also give a warning?—Johan
On Mon, Dec 14, 2015 at 7:08 PM, Jens Persson via swift-dev <swift-dev@swift.org <mailto:swift-dev@swift.org>> wrote:
func ok() {
let s = "see"; "Why are there exactly "
0 == 0 * 42
"warnings and errors in this code"
let t = s + "?"
print(t)
}
ok() // see?_______________________________________________
swift-dev mailing list
swift-dev@swift.org <mailto:swift-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-dev--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
http://www.bitcycle.com/
Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com <mailto:jens@bitcycle.com>_______________________________________________
swift-dev mailing list
swift-dev@swift.org <mailto:swift-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-dev-Dave
--
bitCycle AB | Smedjegatan 12 | 742 32 Östhammar | Sweden
http://www.bitcycle.com/
Phone: +46-73-753 24 62
E-mail: jens@bitcycle.com <mailto:jens@bitcycle.com>_______________________________________________
swift-dev mailing list
swift-dev@swift.org <mailto:swift-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-dev