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.79k stars 2.16k forks source link

cannot use or test a generic function via submodule #5508

Closed Delta456 closed 3 years ago

Delta456 commented 4 years ago

V version: Latest

OS: WSL

What did you do?

import math.stats

fn test_freq() {
    // Tests were also verified on Wolfram Alpha
    data := [f64(10.0), 10.0, 5.9, 2.7]
    mut o := math.stats.freq<f64>(data, 10.0)
    assert o == 2
    o = math.stats.freq<f64>(data, 2.7)
    assert o == 1
    o = math.stats.freq<f64>(data, 15)
    assert o == 0
}

v test file_test.v

What did you expect to see? Tests failing or successful

What did you see instead?

------------------------------------------------------------------------------------ Testing... -----------------------------------------------------------------------------------FAIL  109.375 ms vlib/math/stats/stats_test.v
vlib/math/stats/stats_test.v:7:36: error: unexpected `,`, expecting `)`
    5 |     // Tests were also verified on Wolfram Alpha
    6 |     data := [f64(10.0), 10.0, 5.9, 2.7]
    7 |     mut o := math.stats.freq<f64>(data, 10.0)
      |                                       ^
    8 |     assert o == 2
    9 |     o = math.stats.freq<f64>(data, 2.7)

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------      116.376 ms <=== total time spent running V _test.v files
                 ok, fail, skip, total =     0,     1,     0,     1
larpon commented 4 years ago

@Delta456 - can you provide a full reproducible code snippet?

yuyi98 commented 3 years ago

Fixed. error: a non generic function called like a generic one. math.stats.freq is not generic fn.