vlang / v

Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
MIT License
35.8k stars 2.16k forks source link

Wrong error message when mysql is not imported #13557

Open Lathanao opened 2 years ago

Lathanao commented 2 years ago

V doctor:

OS: linux, Ubuntu 21.04
Processor: 12 cpus, 64bit, little endian, Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
CC version: cc (Ubuntu 10.3.0-1ubuntu1) 10.3.0

getwd: /var/www/vproject
vmodules: /home/tanguy/.vmodules
vroot: /var/www/vproject/v
vexe: /var/www/vproject/v/v
vexe mtime: 2022-02-22 02:56:50
is vroot writable: true
is vmodules writable: true
V full version: V 0.2.4 f8b8950.4a765bc

Git version: git version 2.30.2
Git vroot status: weekly.2022.07-63-g4a765bc3
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 3654d6a8-dirty

What did you do? v -g -o vdbg cmd/v && vdbg /var/www/vproject/test/mysql/bug2.v

module main

fn main() {
    query := 'SELECT * FROM `yo`;'

    mut connection := mysql.Connection{
            username: 'yo'
            password: 'yo'
            dbname: 'yo'
    }

    results := connection.query(query) ?

    println(results)
}

What did you expect to see?

An accurate error message. The current one is wrong. Here, mysql need to be imported.

What did you see instead?

test/mysql/bug2.v:7:14: error: expression evaluated but not used
    5 |     
    6 |     mut connection := mysql.Connection{
    7 |             username: 'yo'
      |                       ~~~~
    8 |             password: 'yo'
    9 |             dbname: 'yo'
JalonSolov commented 1 year ago

Still failing with V 0.4.0 b06811c