akhismat / test-huly

0 stars 0 forks source link

GitHub POST: 22406 compiler crash #126

Open akhismat opened 6 days ago

akhismat commented 6 days ago

the compiler crashed when trying to implement a simple observable

V doctor:

V full version: V 0.4.8 5b1581d
OS: windows, Microsoft Windows 10 Home v19045 64-bit
Processor: 8 cpus, 64bit, little endian, 

getwd: C:\Users\Kenny\source\vtest
vexe: C:\Users\Kenny\source\v\v.exe
vexe mtime: 2024-10-04 05:53:52

vroot: OK, value: C:\Users\Kenny\source\v
VMODULES: OK, value: C:\Users\Kenny\.vmodules
VTMP: OK, value: C:\Users\Kenny\AppData\Local\Temp\v_0

Git version: git version 2.44.0.windows.1
Git vroot status: weekly.2024.18-807-g5b1581da
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,

operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 b425ac82

What did you do? ./v -g -o vdbg cmd/v && ./vdbg Obv.v


// callback types
type CBnoret[T] = fn (val T)
type CBnoret2[T] = fn (val T, prev T)
type CBvret[T] = fn (val T) T
type CBvret2[T] = fn (val T, prev T) T

type Callback[T] = CBnoret[T] | CBnoret2[T] | CBvret[T] | CBvret2[T]

interface IObv[T] {
    v T
    prev T
    cb []Callback[T]
}

struct Obv[T] {
mut:
    v T
    prev T
    cb []Callback
}

fn (o Obv[T]) get () T {
    return o.v
}

fn (o Obv[T]) do_callbacks () T {

    return o.v
}

fn (mut o Obv[T]) set (new_value T) T {
    prev := o.v
    if prev != new_value {
        o.v = new_value
        o.prev = prev

    }

    return o.v
}

fn oo[T](init T) Obv[T] {
    return Obv[T]{v: init}
}

one := oo(1)
txt := oo("lala")

println("done")
println("done ${txt.get()}")
println("one: ${one.get()}")

txt.get()
one.get()

What did you expect to see?

no crash

What did you see instead?

================== C compilation error (from tcc): ==============
cc: C:/Users/Kenny/AppData/Local/Temp/v_0/Obv.01J9B30QWYW070ED4708QEWXXA.tmp.c:530: warning: WINVER redefined
cc: C:/Users/Kenny/AppData/Local/Temp/v_0/Obv.01J9B30QWYW070ED4708QEWXXA.tmp.c:1248: error: ';' expected (got "Array_main__Callback")
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

[!NOTE] You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote. Other reactions and those to comments will not be taken into account.