Skip to content

Commit

Permalink
enhance
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Jan 14, 2025
1 parent 29ce5b8 commit 3668f9d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -4915,7 +4915,7 @@ fn (mut c Checker) index_expr(mut node ast.IndexExpr) ast.Type {
c.error('type `?${typ_sym.name}` is an Option, it must be unwrapped with `func()?`, or use `func() or {default}`',
node.left.pos())
} else if node.left is ast.SelectorExpr && node.left.or_block.kind == .absent {
c.error('type `?${typ_sym.name}` is an Option, it must be unwrapped first; use `struct.var?[]` to do it',
c.error('type `?${typ_sym.name}` is an Option, it must be unwrapped first; use `${node.left}?` to do it',
node.left.pos())
}
} else if typ.has_flag(.result) {
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/option_map_err.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vlib/v/checker/tests/option_map_err.vv:22:13: error: type `?map[string]f64` is an Option, it must be unwrapped first; use `struct.var?[]` to do it
vlib/v/checker/tests/option_map_err.vv:22:13: error: type `?map[string]f64` is an Option, it must be unwrapped first; use `op2.opmap?` to do it
20 | }
21 | }
22 | assert op2.opmap['1'] == 1.0
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/checker/tests/selector_expr_opt_map_get_err.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vlib/v/checker/tests/selector_expr_opt_map_get_err.vv:8:9: error: type `?map[string]string` is an Option, it must be unwrapped first; use `struct.var?[]` to do it
vlib/v/checker/tests/selector_expr_opt_map_get_err.vv:8:9: error: type `?map[string]string` is an Option, it must be unwrapped first; use `x.m?` to do it
6 | fn main() {
7 | x := Abc{}
8 | _ := x.m['test'] or { 'test' }
Expand Down

0 comments on commit 3668f9d

Please sign in to comment.