v
v copied to clipboard
cgen bug when using sqlite and orm
V doctor:
OS: linux, Ubuntu 20.04.3 LTS
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz
CC version: cc (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
getwd: /v/cleanv
vmodules: /home/delian/.vmodules
vroot: /v/cleanv
vexe: /v/cleanv/v
vexe mtime: 2022-04-16 07:44:39
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.4 4a71b27
Git version: git version 2.25.1
Git vroot status: weekly.2022.15-59-g5b7e5381
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 3654d6a8
What did you do?
v -g -o vdbg cmd/v && vdbg cgen_bug_when_using_sqlite_and_orm.v
import db.sqlite
pub struct DataStore {
db sqlite.DB
}
[table: 'network_port']
struct NetworkPort {
id int [primary; sql: serial]
project_id int
pub:
number int [required; unique: 'number']
label string [required]
}
pub fn (wd DataStore) delete_network_ports(network_ports []NetworkPort) ! {
if network_ports.len == 0 {
return
}
network_port_ids := network_ports.map(it.id)
sql wd.db {
delete from NetworkPort where id in network_port_ids
}!
}
What did you expect to see?
A compiled program.
What did you see instead?
==================
/tmp/v_1000/cgen_bug_when_using_sqlite_and_orm.11091892002973674872.tmp.c:39344: warning: cast between pointer and integer of different size
tcc: error: undefined symbol 'orm__Array_int_to_primitive'
...
==================
(Use `v -cg` to print the entire error message)
builder error:
==================
C error. This should never happen.
This is a compiler bug, please report it using `v bug file.v`.
https://github.com/vlang/v/issues/new/choose
You can also use #help on Discord: https://discord.gg/vlang
Edit: 2023/04/18 - updated the example to latest V, the cgen problem still remains
where id in network_port_ids
is not currently supported in sql?
where id in network_port_ids
is not currently supported in sql?
It cannot seem to generate the correct code from []int