NoReturn

The NoReturn aspect marks a method as never returning execution flow to the caller – for example because it is known to run indefinitely, throw an exception, or terminate the process.

The aspect has no effect on the generated code, but it can assists the compiler with code flow analysis, such as for detecting unreachable code or uninitialized variables.

Attaching the NoReturn aspect to a method is the same as declaring it to return the special Never type in Swift.

[NoReturn]
method RunForever; 
begin
  loop 
    writeLn('Hello');
end;
[NoReturn]
void RunForever()
{
    while (true) 
        writeLn("Hello");
}
[NoReturn]
func RunForever() {
    while true {
        writeLn("Hello");
    }
}
@NoReturn
void RunForever()
{
    while (true) 
        writeLn("Hello");
}

See Also