parser,checker,ast: support @[must_use] tag for fns/methods, and an experimental -check-result option (#22983)

This commit is contained in:
Delyan Angelov 2024-11-27 07:11:40 +02:00 committed by GitHub
parent 4897d7860e
commit 844d89fd09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 108 additions and 4 deletions

View file

@ -5896,6 +5896,18 @@ fn C.DefWindowProc(hwnd int, msg int, lparam int, wparam int)
@[callconv: 'fastcall']
type FastFn = fn (int) bool
// Calls to the following function, will have to use its return value somehow.
// Ignoring it, will emit warnings.
@[must_use]
fn f() int {
return 42
}
fn g() {
// just calling `f()` here, will produce a warning
println(f()) // this is fine, because the return value was used as an argument
}
// Windows only (and obsolete; instead of it, use `-subsystem windows` when compiling)
// Without this attribute all graphical apps will have the following behavior on Windows:
// If run from a console or terminal; keep the terminal open so all (e)println statements can be viewed.