Skip to content

Commit

Permalink
add more check
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Jan 18, 2025
1 parent 897257a commit 4a2c3ce
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion vlib/v/checker/infix.v
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type {
if typ != ast.no_type {
typ_sym := c.table.sym(typ)
op := node.op.str()
if left_type.has_flag(.option) {
if left_type.has_flag(.option) && !c.inside_sql {
c.error('${node.left} is an Optional, it needs to be unwrapped first',
node.left.pos())
}
Expand Down
14 changes: 0 additions & 14 deletions vlib/v/checker/tests/orm_op_with_option_and_none.out
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,3 @@ vlib/v/checker/tests/orm_op_with_option_and_none.vv:45:30: warning: comparison w
| ~~
46 | }!
47 |
vlib/v/checker/tests/orm_op_with_option_and_none.vv:49:25: error: name is an Optional, it needs to be unwrapped first
47 |
48 | _ := sql db {
49 | select from Foo where name is none
| ~~~~
50 | }!
51 |
vlib/v/checker/tests/orm_op_with_option_and_none.vv:53:25: error: name is an Optional, it needs to be unwrapped first
51 |
52 | _ := sql db {
53 | select from Foo where name !is none
| ~~~~
54 | }!
55 | }

0 comments on commit 4a2c3ce

Please sign in to comment.