mirror of
https://github.com/vlang/v.git
synced 2025-09-14 01:47:30 -04:00
parent
f7841e125b
commit
ae899e67fe
@ -1154,6 +1154,7 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
|
||||
}
|
||||
if idx == 0 {
|
||||
c.error('unknown enum `${enum_name}`', node.pos)
|
||||
continue_check = false
|
||||
return ast.void_type
|
||||
}
|
||||
|
||||
|
18
vlib/v/checker/tests/unkown_enum_call_err.out
Normal file
18
vlib/v/checker/tests/unkown_enum_call_err.out
Normal file
@ -0,0 +1,18 @@
|
||||
vlib/v/checker/tests/unkown_enum_call_err.vv:8:9: error: unknown enum `HashFnX`
|
||||
6 |
|
||||
7 | fn test_main() {
|
||||
8 | assert HashFnX.from_string('sha256') or { HashFn.sha1 } == HashFn.sha256
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
9 | }
|
||||
vlib/v/checker/tests/unkown_enum_call_err.vv:8:39: error: unexpected `or` block, the function `HashFnX__static__from_string` does not return an Option or a Result
|
||||
6 |
|
||||
7 | fn test_main() {
|
||||
8 | assert HashFnX.from_string('sha256') or { HashFn.sha1 } == HashFn.sha256
|
||||
| ~~~~~~~~~~~~~~~~~~
|
||||
9 | }
|
||||
vlib/v/checker/tests/unkown_enum_call_err.vv:8:9: error: assert can be used only with `bool` expressions, but found `void` instead
|
||||
6 |
|
||||
7 | fn test_main() {
|
||||
8 | assert HashFnX.from_string('sha256') or { HashFn.sha1 } == HashFn.sha256
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
9 | }
|
9
vlib/v/checker/tests/unkown_enum_call_err.vv
Normal file
9
vlib/v/checker/tests/unkown_enum_call_err.vv
Normal file
@ -0,0 +1,9 @@
|
||||
enum HashFn {
|
||||
sha1
|
||||
sha256
|
||||
sha512
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
assert HashFnX.from_string('sha256') or { HashFn.sha1 } == HashFn.sha256
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user