Skip to content

Compiler segfaults when trying to increment a constant at comptime #25645

@pfgithub

Description

@pfgithub

Zig Version

0.16.0-dev.747+493ad58ff

Steps to Reproduce and Observed Behavior

pub fn main() !void {
    const x = 0;
    comptime {
        x += std.math.add(usize, x, 2);
    }
}
const std = @import("std");
$> zig run a.zig
fish: Job 1, 'zig' terminated by signal SIGSEGV (Address boundary error)
Exited with code [SIGSEGV]

Expected Behavior

"Cannot assign to constant", or a similar error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions