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.5k stars 2.15k forks source link

builder error: struct or union expected #21721

Closed Eliyaan closed 4 days ago

Eliyaan commented 4 days ago

Describe the bug

When compiling the code it outputs a builder error.

Reproduction Steps

struct Parse {
mut:
        stack []&Element
}

struct Balise {}

struct RawText {}

type Element = Balise | RawText

fn (mut p Parse) process_open_tag() {
        mut last := &p.stack[0]
        if mut last is RawText {
        }
}

Expected Behavior

No builder error or an error explaining what is wrong.

Current Behavior

❯ v run main.v
==================
/tmp/v_1000/main.01J1506VYF091BH3R85WEJH7MS.tmp.c:13185: error: struct or union expected
...
==================
(Use `v -cg` to print the entire error message)

builder error

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.6 294f7e4.4d2c2da

Environment details (OS name and version, etc.)

OS: linux, Linux version 6.7.11-200.fc39.x86_64 (mockbuild@bdb8d24f206645e2bda44c1cf867612d) (gcc (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7), GNU ld version 2.40-14.fc39) #1 SMP PREEMPT_DYNAMIC Wed Mar 27 16:50:39 UTC 2024

[!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.

JalonSolov commented 4 days ago

Compiling with v -g main.v shows the problem to be on line 14... this line:

        if mut last is RawText {