parser: handle `[noreturn]` on methods too

pull/12938/head
Delyan Angelov 2021-12-22 19:58:22 +02:00
parent 1028f0b59e
commit db1175e455
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1 @@
Test.zz_exit called, as it should

View File

@ -0,0 +1,19 @@
struct Test {}
[noreturn]
fn (mut t Test) zz_exit() {
println('${@METHOD} called, as it should')
flush_stdout()
exit(0)
}
fn optional() ?int {
return error('oh no')
}
fn main() {
mut test := Test{}
a := optional() or { test.zz_exit() }
println(a)
exit(1)
}

View File

@ -399,6 +399,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
generic_names: generic_names generic_names: generic_names
is_pub: is_pub is_pub: is_pub
is_deprecated: is_deprecated is_deprecated: is_deprecated
is_noreturn: is_noreturn
is_unsafe: is_unsafe is_unsafe: is_unsafe
is_main: is_main is_main: is_main
is_test: is_test is_test: is_test