mirror of
https://github.com/vlang/v.git
synced 2025-09-18 03:46:36 -04:00
parent
1eb3867f4e
commit
31ce668c7a
7
vlib/v/checker/tests/orm_unused_var.out
Normal file
7
vlib/v/checker/tests/orm_unused_var.out
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
vlib/v/checker/tests/orm_unused_var.vv:15:2: warning: unused variable: `x_id`
|
||||||
|
13 |
|
||||||
|
14 | x := Test{}
|
||||||
|
15 | x_id := sql db {
|
||||||
|
| ~~~~
|
||||||
|
16 | insert x into Test
|
||||||
|
17 | } or { panic(err) }
|
18
vlib/v/checker/tests/orm_unused_var.vv
Normal file
18
vlib/v/checker/tests/orm_unused_var.vv
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import db.sqlite
|
||||||
|
|
||||||
|
struct Test {
|
||||||
|
id int @[primary; serial]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
db := sqlite.connect(':memory:')!
|
||||||
|
|
||||||
|
sql db {
|
||||||
|
create table Test
|
||||||
|
}!
|
||||||
|
|
||||||
|
x := Test{}
|
||||||
|
x_id := sql db {
|
||||||
|
insert x into Test
|
||||||
|
} or { panic(err) }
|
||||||
|
}
|
@ -20,6 +20,7 @@ const skip_on_ubuntu_musl = [
|
|||||||
'vlib/v/checker/tests/vweb_tmpl_used_var.vv',
|
'vlib/v/checker/tests/vweb_tmpl_used_var.vv',
|
||||||
'vlib/v/checker/tests/vweb_routing_checks.vv',
|
'vlib/v/checker/tests/vweb_routing_checks.vv',
|
||||||
'vlib/v/checker/tests/orm_op_with_option_and_none.vv',
|
'vlib/v/checker/tests/orm_op_with_option_and_none.vv',
|
||||||
|
'vlib/v/checker/tests/orm_unused_var.vv',
|
||||||
'vlib/v/tests/skip_unused/gg_code.vv',
|
'vlib/v/tests/skip_unused/gg_code.vv',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ fn (mut p Parser) sql_expr() ast.Expr {
|
|||||||
mut is_count := false
|
mut is_count := false
|
||||||
if is_insert {
|
if is_insert {
|
||||||
inserted_var = p.check_name()
|
inserted_var = p.check_name()
|
||||||
|
p.scope.mark_var_as_used(inserted_var)
|
||||||
into := p.check_name()
|
into := p.check_name()
|
||||||
if into != 'into' {
|
if into != 'into' {
|
||||||
p.error('expecting `into`')
|
p.error('expecting `into`')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user