v
v copied to clipboard
Aliases (`type`) cause compiler `c errors`
trafficstars
V version:
V 0.2.2 2bcc733
OS: Artix Linux
What did you do?
//file name: uuid_test.v
type UUID = [16]byte
const codec_test_uuid = UUID([byte(0x6b), 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4,
0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8]!)
fn test_from_bytes() {assert true}
# running
v test uuid_test.v
What did you expect to see? test passes
What did you see instead?
builder error:
==================
C error. This should never happen.
If you were not working with C interop, this is a compiler bug, please report the bug using `v bug file.v`.
also
pasting this to a v shell causes a builder error
type Line = string
fn (l Line) parse_line() string {
return l[0..1]
}
Another one here!
Version: V 0.2.2 5cfe55b OS: Manjaro Linux
struct Just<T> { value T }
struct None {}
type Maybe = Just<T> | None
// ^^^^^^^ C builder error
fn main() {
println("hello world")
}
This is what compiler error looks like (with the -cg flag for clarity):
↪ v -cg main.v
/tmp/v/main.6460802920068751022.tmp.c:680: error: ';' expected (got "main__Just_T_T")
builder error:
==================
C error. This should never happen.
If you were not working with C interop, this is a compiler bug, please raise an issue on GitHub:
https://github.com/vlang/v/issues/new/choose
You can also use #help on Discord: https://discord.gg/vlang
I tried using
type Maybe = Just<T> | None
because I couldn't get Maybe do be polymorphic itself like this
type Maybe<T> = Just<T> | None
which gives an error, so I'm assuming V doesn't support polymorphic union types yet :(