Skip to content

Using .always_tail on an inline function with a comptime parameter causes a compiler crash. #24837

@IridescentRose

Description

@IridescentRose

Zig Version

0.14.1

Steps to Reproduce and Observed Behavior

Minimal Reproduction Code:

const std = @import("std");

var counter: usize = 0;

inline fn tail_call(
    comptime Target: type,
) std.mem.Allocator.Error!void {
    // Arbitrary condition for tailing
    if (counter >= 1024) return;
    counter += 1;

    @setEvalBranchQuota(10_000);
    try @call(.always_tail, tail_call, .{
        Target,
    });
}

pub fn main() !void {
    try tail_call(f32);
}

Simply building under any mode: Debug, Release* causes this behavior, e.g. zig build-exe test.zig
This results in segmentation fault.

Expected Behavior

Expected an error message stating that tail calling an inline function is illegal, which does happen without the comptime parameter: error: inline call is recursive

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions