mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
parser,checker,ast: support @[must_use]
tag for fns/methods, and an experimental -check-result
option (#22983)
This commit is contained in:
parent
4897d7860e
commit
844d89fd09
8 changed files with 108 additions and 4 deletions
12
doc/docs.md
12
doc/docs.md
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue