Skip to content

Invalid code compiles in comptime #21405

Description

@PanSashko

Zig Version

0.14.0-dev.1550+4fba7336a

Steps to Reproduce and Observed Behavior

The following code compiles

test {
constx: ?u32=10;
_=comptimeif (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'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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