V: Import Module Issue

Created on 3 Nov 2020  路  7Comments  路  Source: vlang/v


V version:
OS: linux, Linux version 5.4.38-gentoo (root@plasma) (gcc version 9.3.0 (Gentoo 9.3.0 p2)) #7 SMP Sat May 30 02:30:58 CEST 2020

What did you do?

module check

pub struct Point {
pub mut:
    x   int
    y   int
}

pub struct Line {
pub mut:
    ps  []Point
}

module main

import check { Point Line }


fn main() {
    p0 := Point  {x: 10 y: 10}
    p1 := Point  {x: 50 y: 10}

    ln := Line {
        ps: [p0, p1]
    }

}

What did you expect to see?
No problem

What did you see instead?

error: cannot assign to field `ps`: expected `[]check.Point`, not `[]Point`
    9 | 
   10 |     ln := Line {
   11 |         ps: [p0, p1]
Bug

Most helpful comment

Most recent version of V as of 7 hours ago (6 hours before your last comment) is V 0.1.29 a2fc198, so you do not have the latest version. That's why @serkonda7 suggested doing v up first.

All 7 comments

try this:

module main

import check { Point, Line }

fn main() {
    p0 := Point  {x: 10 y: 10}
    p1 := Point  {x: 50 y: 10}

    ln := Line {
        ps: [p0, p1]
    }
}

@StunxFS same error
This is not critical. I avoid the problem using

p0 := check.Point {10,10}

but if V permits the import of Point and Line, the use of check.Point is not elegant to a promising language as V.
I also compile a V progam and lost memory, I try to find how I can repeat the code for simple to report!! But this is another history...

I also compile a V progam and lost memory, I try to find how I can repeat the code for simple to report!! But this is another history...

Uff...

This is not critical. I avoid the problem using

p0 := check.Point {10,10}

but if V permits the import of Point and Line, the use of check.Point is not elegant to a promising
language as V.

I'd say the custom symbol import system is a work in progress.

As far as I remember this issue was fixed a long time ago. Please run v up and try again.

As far as I remember this issue was fixed a long time ago. Please run v up and try again.

imagen

Most recent version of V as of 7 hours ago (6 hours before your last comment) is V 0.1.29 a2fc198, so you do not have the latest version. That's why @serkonda7 suggested doing v up first.

Updating V...
V self compiling ...
Current V version:
V 0.1.29 785bf40
xxxx.v:10:5: warning: unused variable: `ln`
    8 |     p1 := Point  {x: 50 y: 10}
    9 | 
   10 |     ln := Line {
      |     ~~
   11 |         ps: [p0, p1]
   12 |     }
xxxx.v:11:9: error: cannot assign to field `ps`: expected `[]check.Point`, not `[]Point`
    9 | 
   10 |     ln := Line {
   11 |         ps: [p0, p1]
      |         ~~~~~~~~~~~~
   12 |     }
   13 |

Same result!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

elimisteve picture elimisteve  路  3Comments

markgraydev picture markgraydev  路  3Comments

lobotony picture lobotony  路  3Comments

radare picture radare  路  3Comments

choleraehyq picture choleraehyq  路  3Comments