Skip to content

Invalid code compiles in comptime #21405

@PanSashko

Description

@PanSashko

Zig Version

0.14.0-dev.1550+4fba7336a

Steps to Reproduce and Observed Behavior

The following code compiles

test {
    const x: ?u32 = 10;
    _ = comptime if (x) x.f();
}

That might cause a confusing bug in more complex cases, when the function f actually exists in x.

Expected Behavior

Like without comptime the compilation should fail with

error: expected type 'bool', found '?u32'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions