Skip to content

Or block with a build time if check does not build on Linux #28018

Description

@vlOd2

Describe the bug

Compiling bug.v under Linux (or cross compiling from Windows) causes a build failure

Reproduction Steps

./v -g -o vdbg cmd/v && ./vdbg -os linux "bug.v" && "./bug"
fn my_erroring_function(_ int) !u32 {
	return error('!')
}

fn main() {
	x := my_erroring_function(1) or {
		$if !windows {
			panic(err)
		} $else {
			u32(0)
		}
	}
	println(x)
}

Expected Behavior

A successful build

Current Behavior

Cross compilation for Linux failed (first step, cc). Make sure you have clang installed.
builder error: ...\AppData\Local\Temp\v_0\bug.01KZ4EX56WSKGEY04ME1RTRMRT.tmp.c:4489:4: error: use of undeclared identifier '_t3'
 4489 |                         _t3 = builtin___v_panic(builtin__IError_str(err));
      |                         ^~~
...\AppData\Local\Temp\v_0\bug.01KZ4EX56WSKGEY04ME1RTRMRT.tmp.c:4494:3: error: use of undeclared identifier '_t3'
 4494 |                 _t3;
      |                 ^~~
2 errors generated.

Possible Solution

The V compiler seems to generate the following for the or block:

if (_t1.is_error) {
        IError _t2 = _t1.err;
        IError err = _t2;
        #if 1
            _t3 = builtin___v_panic(builtin__IError_str(err));
            VUNREACHABLE();
            ;
        #else
        #endif
        _t3;
    }

_t3 isn't declared anywhere, so it errors out (error: use of undeclared identifier '_t3')
but it doesn't even make sense to assign the result to a _t3 since it's a void function (probably why _t3 wasn't created)

Additional Information/Context

No response

V version

V 0.5.2 1cbcde2

Environment details (OS name and version, etc.)

|V full version      |V 0.5.2 0d38e8ad083e4e16058bfa5e2255d387e55ef2f0.1cbcde2
|:-------------------|:-------------------
|OS                  |windows,   
|Processor           |4 cpus, 64bit, little endian, N/A
|Memory              |7.74GB/15.95GB
|                    |
|V executable        |E:\SDK\vlang\v.exe
|V last modified time|2026-07-30 13:03:19
|                    |
|V home dir          |OK, value: E:\SDK\vlang
|VMODULES            |OK, value: ...\.vmodules
|VTMP                |OK, value: ...\AppData\Local\Temp\v_0
|Current working dir |OK, value: ...\Desktop\bug
|                    |
|Git version         |git version 2.53.0.windows.3
|V git status        |N/A
|.git/config present |false
|                    |
|cc version          |clang version 22.1.8 (https://github.com/llvm/llvm-project.git ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
|gcc version         |clang version 22.1.8 (https://github.com/llvm/llvm-project.git ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
|clang version       |clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
|msvc version        |N/A
|tcc version         |tcc version 0.9.28rc 2026-07-14_HEAD@d9d02c56* (x86_64 Windows)
|tcc git status      |thirdparty-windows-amd64 f7c7199b-dirty
|emcc version        |N/A
|glibc version       |N/A

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions