Skip to content

async: Using switch result in expression leads to invalid llvm #4188

@frmdstryr

Description

@frmdstryr

This works:

        // Wait until the first byte is received
        var n = try serial.read(in_buf[0..1]);
        const r = serial.readUntilTimeout(in_buf[1..], 100) catch |err| switch (err) {
            error.Timeout => serial.rx_index,
            else => return err,
        };
        n += r;

but this doesn't

        // Wait until the first byte is received
        var n = try serial.read(in_buf[0..1]);

        // Read the rest (if any)
        n += serial.readUntilTimeout(in_buf[1..], 100) catch |err| switch (err) {
            error.Timeout => serial.rx_index,
            else => return err,
        };

the error is:

Semantic Analysis [174/623] broken LLVM module found: Instruction does not dominate all uses!
  %169 = load i32, i32* %51, align 4, !dbg !4213
  %168 = phi i32 [ %160, %SwitchEnd ], [ %169, %UnwrapErrOk ], !dbg !4213

Signature

pub fn readUntilTimeout(self: *UART, buffer: []u8, timeout: u32) !usize {

It happens even if I use else=> 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions