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:
@@ -185,8 +185,10 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||
mut is_exported := false
|
||||
mut is_unsafe := false
|
||||
mut is_trusted := false
|
||||
mut is_noreturn := false
|
||||
for fna in p.attrs {
|
||||
match fna.name {
|
||||
'noreturn' { is_noreturn = true }
|
||||
'manualfree' { is_manualfree = true }
|
||||
'deprecated' { is_deprecated = true }
|
||||
'direct_array_access' { is_direct_arr = true }
|
||||
@@ -408,6 +410,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||
generic_names: generic_names
|
||||
is_pub: is_pub
|
||||
is_deprecated: is_deprecated
|
||||
is_noreturn: is_noreturn
|
||||
is_unsafe: is_unsafe
|
||||
is_main: is_main
|
||||
is_test: is_test
|
||||
@@ -449,6 +452,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||
return_type: return_type
|
||||
return_type_pos: return_type_pos
|
||||
params: params
|
||||
is_noreturn: is_noreturn
|
||||
is_manualfree: is_manualfree
|
||||
is_deprecated: is_deprecated
|
||||
is_exported: is_exported
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
vlib/v/parser/tests/or_default_missing.vv:4:3: error: `or` block must provide a default value of type `int`, or return/exit/continue/break/panic
|
||||
vlib/v/parser/tests/or_default_missing.vv:4:3: error: `or` block must provide a default value of type `int`, or return/continue/break or call a [noreturn] function like panic(err) or exit(1)
|
||||
2 | m := [3, 4, 5]
|
||||
3 | el := m[4] or {
|
||||
4 | println('error')
|
||||
|
||||
Reference in New Issue
Block a user