1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

all: support [noreturn] fn abc() { for{} }, mark panic/1 and exit/1with it too. (#10654)

This commit is contained in:
Delyan Angelov
2021-07-04 20:24:19 +03:00
committed by GitHub
parent b0b4b8e65b
commit 6aecda3be8
23 changed files with 318 additions and 22 deletions

View File

@@ -4763,6 +4763,21 @@ fn legacy_function() {}
fn inlined_function() {
}
// This function's calls will NOT be inlined.
[noinline]
fn function() {
}
// This function will NOT return to its callers.
// Such functions can be used at the end of or blocks,
// just like exit/1 or panic/1. Such functions can not
// have return types, and should end either in for{}, or
// by calling other `[noreturn]` functions.
[noreturn]
fn forever() {
for {}
}
// The following struct must be allocated on the heap. Therefore, it can only be used as a
// reference (`&Window`) or inside another reference (`&OuterStruct{ Window{...} }`).
[heap]